gpt4 book ai didi

audio - 从原始MP3中剥离ID TAGS

转载 作者:行者123 更新时间:2023-12-03 01:04:46 24 4
gpt4 key购买 nike

我想得到一个干净的Mp3文件,没有任何附加数据,例如id标签,封面图像,编码器信息或其他内容。
只有有效文件中的mp3,才能播放每个mp3播放器。

我从这个开始:
Access MP3 audio data independently of ID3 tags?
http://code.google.com/p/kodebucket/source/browse/trunk/bin/mp3dump.rb

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

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

最佳答案

这个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

关于audio - 从原始MP3中剥离ID TAGS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4111378/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com