从原始 MP3 中剥离 ID 标签

发布于 2024-10-01 01:52:02 字数 502 浏览 2 评论 0原文

我想获得一个干净的 Mp3 文件,没有任何其他数据,如 id 标签、封面图像、编码器信息或其他数据。 只要是有效文件中的mp3,就可以播放每个mp3播放器。

我从这个开始: 独立于 ID3 标签访问 MP3 音频数据? http://code.google.com/p/ kodebucket/source/browse/trunk/bin/mp3dump.rb

获取没有 id 标签的 mp3 的有效哈希值效果很好,但是当您将输出保存到 mp3 文件中时,它就损坏了。

也许您有一个想法,如何完成这项工作。

I want to get an clean Mp3 File, without any aditional data like id Tags, Cover Image, encoder info or what else.
Just the mp3 in an valid file, wich can play every mp3 player.

I started with this one:
Access MP3 audio data independently of ID3 tags?
http://code.google.com/p/kodebucket/source/browse/trunk/bin/mp3dump.rb

It works nice to get an valid hash of the mp3 without id Tags, but when you save the output into an mp3 file, it's broken.

Maybe you have there an idea, how to get this work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萝莉病 2024-10-08 01:52:02

使用这个 Ruby 库应该非常简单:

http://unixgods.org /~tilo/Ruby/ID3/docs/index.html

最好是 0.5.0 或更高版本,

安装 gem 后检查“examples”目录中的文件,

require 'id3'

filename = "bla.mp3"
if ID3.hasID3v1tag?( filename ) || ID3.hasID3v2tag?( filename )

   puts "File size: #{ File::Stat.new(filename).size }"   # file size including tags

   myfile = ID3::AudioFile.new( filename )
   puts "Audio length: #{myfile.audioLength}"    
   puts "Audio MD5sum: #{myfile.audioMD5sum}"

   # delete both id3 v1 and id3 v2 tags from the file:
   myfile.tagID3v1 = nil     # it might be a good idea to store the info somewhere before deleting it
   myfile.tagID3v2 = nil
   myfile.write              # we only write if we modified it..

end

例如:在 irb 中交互测试

# /usr/bin/irb
irb> RUBY_VERSION
 => "1.8.6" 
irb>  require 'id3'   # version 0.5.0
 => true 
irb> filename = '/tmp/b.mp3'
 => "/tmp/b.mp3" 
irb>      puts "File size: #{ File::Stat.new(filename).size }"
File size: 8040064
irb>      myfile = ID3::AudioFile.new( filename )
irb>    puts "Audio length: #{myfile.audioLength}"    
Audio length: 8037877
irb>    puts "Audio MD5sum: #{myfile.audioMD5sum}"
Audio MD5sum: 47719e1881e5a2488e51fc250ccd2396
irb>       # /usr/bin/irb
irb> RUBY_VERSION
 => "1.8.6" 
irb>  require 'id3'   # version 0.5.0
 => true 
irb> filename = '/tmp/b.mp3'
 => "/tmp/b.mp3" 
irb>      puts "File size: #{ File::Stat.new(filename).size }"
File size: 8040064
irb>      myfile = ID3::AudioFile.new( filename )
irb>    puts "Audio length: #{myfile.audioLength}"    
Audio length: 8037877
irb>    puts "Audio MD5sum: #{myfile.audioMD5sum}"
Audio MD5sum: 47719e1881e5a2488e51fc250ccd2396
irb> myfile.tagID3v2
 => {"ARTIST"=>{"encoding"=>0, "text"=>"Juno reactor"}, "CONTENTTYPE"=>{"encoding"=>0, "text"=>"Electronica/Dance"}, "ALBUM"=>{"encoding"=>0, "text"=>"Bible of Dreams"}, "ENCODEDBY"=>{"encoding"=>0, "text"=>"iTunes v2.0"}, "TRACKNUM"=>{"encoding"=>0, "text"=>"6/9"}, "TITLE"=>{"encoding"=>0, "text"=>"Kaguya Hime"}, "YEAR"=>{"encoding"=>0, "text"=>"1997"}, "COMMENT"=>{"encoding"=>0, "language"=>"eng", "short"=>"iTunes_CDDB_IDs", "long"=>"9+647C467468A248173A4A203ED2204CAB+163399"}} 

irb>      myfile.tagID3v1 = nil
irb>      myfile.tagID3v2 = nil
irb>      myfile.write
irb>  puts "File size: #{ File::Stat.new(filename).size }"
File size: 8037877

it should be pretty straight forward with this Ruby library:

http://unixgods.org/~tilo/Ruby/ID3/docs/index.html

preferably version 0.5.0 or higher

check the files in the 'examples' directory once the gem is installed

require 'id3'

filename = "bla.mp3"
if ID3.hasID3v1tag?( filename ) || ID3.hasID3v2tag?( filename )

   puts "File size: #{ File::Stat.new(filename).size }"   # file size including tags

   myfile = ID3::AudioFile.new( filename )
   puts "Audio length: #{myfile.audioLength}"    
   puts "Audio MD5sum: #{myfile.audioMD5sum}"

   # delete both id3 v1 and id3 v2 tags from the file:
   myfile.tagID3v1 = nil     # it might be a good idea to store the info somewhere before deleting it
   myfile.tagID3v2 = nil
   myfile.write              # we only write if we modified it..

end

e.g.: testing this interactively in irb

# /usr/bin/irb
irb> RUBY_VERSION
 => "1.8.6" 
irb>  require 'id3'   # version 0.5.0
 => true 
irb> filename = '/tmp/b.mp3'
 => "/tmp/b.mp3" 
irb>      puts "File size: #{ File::Stat.new(filename).size }"
File size: 8040064
irb>      myfile = ID3::AudioFile.new( filename )
irb>    puts "Audio length: #{myfile.audioLength}"    
Audio length: 8037877
irb>    puts "Audio MD5sum: #{myfile.audioMD5sum}"
Audio MD5sum: 47719e1881e5a2488e51fc250ccd2396
irb>       # /usr/bin/irb
irb> RUBY_VERSION
 => "1.8.6" 
irb>  require 'id3'   # version 0.5.0
 => true 
irb> filename = '/tmp/b.mp3'
 => "/tmp/b.mp3" 
irb>      puts "File size: #{ File::Stat.new(filename).size }"
File size: 8040064
irb>      myfile = ID3::AudioFile.new( filename )
irb>    puts "Audio length: #{myfile.audioLength}"    
Audio length: 8037877
irb>    puts "Audio MD5sum: #{myfile.audioMD5sum}"
Audio MD5sum: 47719e1881e5a2488e51fc250ccd2396
irb> myfile.tagID3v2
 => {"ARTIST"=>{"encoding"=>0, "text"=>"Juno reactor"}, "CONTENTTYPE"=>{"encoding"=>0, "text"=>"Electronica/Dance"}, "ALBUM"=>{"encoding"=>0, "text"=>"Bible of Dreams"}, "ENCODEDBY"=>{"encoding"=>0, "text"=>"iTunes v2.0"}, "TRACKNUM"=>{"encoding"=>0, "text"=>"6/9"}, "TITLE"=>{"encoding"=>0, "text"=>"Kaguya Hime"}, "YEAR"=>{"encoding"=>0, "text"=>"1997"}, "COMMENT"=>{"encoding"=>0, "language"=>"eng", "short"=>"iTunes_CDDB_IDs", "long"=>"9+647C467468A248173A4A203ED2204CAB+163399"}} 

irb>      myfile.tagID3v1 = nil
irb>      myfile.tagID3v2 = nil
irb>      myfile.write
irb>  puts "File size: #{ File::Stat.new(filename).size }"
File size: 8037877
用心笑 2024-10-08 01:52:02

如果您使用的是 Linux 或 Mac,请尝试 BulkID3。 http://sourceforge.net/projects/bulkid3

Try BulkID3 if you're using Linux or Mac. http://sourceforge.net/projects/bulkid3

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文