Mp3Fixer
Source (link to git-repo or to original if based on someone elses unmodified work):
For example, if you have a track that you know is really five minutes long, but amaroK shows the length as one hour, then this script is for you. Mp3Fixer calculates the real track length and adds the missing XING header to the file, and it also repairs broken MPEG headers.
It is recommended that you back up your MP3 file before using this script on it. Although the script is designed not to harm your file, the operation is not reversible and should therefore be used with caution.
Dependencies:
* amaroK 1.3.1
* Ruby 1.8
Version 0.9.4:
* Fixed potential runtime error with some files.
Version 0.9.3:
* Show detailed repair summary.
* Some mp3 encoders (e.g. lame) add a block of zeros as padding to the beginning of the file. This is now correctly handled.
* mp3fix.rb did not work with source != destination.
Version 0.9.2:
* Automatically update the collection after repairing files.
* Automatically refresh the playlist.
Version 0.9.1:
* Fixed a bug that could make the script crap out with a runtime error.
* Show current filename in the statusbar.
Version 0.9:
* mp3fix.rb can now repair broken MPEG frames.
* Batch processing of multiple selected files.
* Using amaroK's statusbar for feedback instead of kdialog. This means, KDE-base is no longer required.
* More reliable, better error checking.
Ratings & Comments
37 Comments
I really wish this would be available for Amarok 2... Is there a chance to add something like this?
The script incorrectly reads the channel mode of the mp3 and thus looks for xing header in the wrong place with mono mp3. Line 115 ChannelMode = data[offset + 3] & 0xc0 >> 6 Should be ChannelMode = (data[offset + 3] & 0xc0) >> 6 As >> has higher precedence than &. Channel mode is the first two bits of the third byte of the frame header. This causes the script to look for a xing header in the wrong place with mono files. When it doesn't find one it proceeds to write a new one in the wrong place. This bug is further complicated by the fact there is a similar bug in the current 1.4 release of taglib (fixed in svn) that causes it to make the same mistake when looking for a xing header in a mono mp3. This makes it look like the script works as the track length will be correct in amarok but could cause problems with other software and when a newer version of taglib is released that looks for xing headers in the correct place.
Seems that script failed with UTF-8 ID3v2 headers. I have MP3 which plays fine in Audacious, but not in iPod Nano. I try to fix it using mp3fix and now I can even upload MP3 to iPod. :(
I have experienced similar problems with ID3v2.3 and UTF-8. The tags where often messed up even though Mp3Fixer did its job correctly. I had to clear off every tags from the files, run Mp3Fixer on them and lastly put the tags back.
Works perfectly for me, thanks for the script.
What the?! I selected all songs and started "FixMp3". Now the beginning of some songs are the end of the song, so amarok plays the end of some songs and then goes to the next song. I really hope my music collection isn't destroyed! Is there anything I can do? (Totem plays the end as the beginning as well)
Weird. Sorry to hear that. I hope you made a backup before using the script, as I recommended. If you still have one of the original files (before using the script), could you send me one? markey@web.de
It doesn't work for me, either. It crashes with "Division Error" no matter what MP3 file I try it on: mp3fix.rb 050710\ 1358\ SIM.mp3 ID3-V2 detected. Tag size: 664 Analyzing mpeg frames.. ./mp3fix.rb:184:in `/': divided by 0 (ZeroDivisionError) from ./mp3fix.rb:184 Line 184 looks like this: AverageBitrate = bitrateCount / frameCount All my files play fine. They were encoded with LAME. I tested both from the console and from within Amarok. The results were the same.
That's strange.Can you send me one of these files? markey@web.de
.kde/share/apps/amarok/scripts-data/mp3fixer/mp3fixer.rb /home/adrian/Various-Unknown_Album/8.mp3 .kde/share/apps/amarok/scripts-data/mp3fixer/mp3fixer.rb:29: private method `chomp' called for nil:NilClass (NoMethodError) from .kde/share/apps/amarok/scripts-data/mp3fixer/mp3fixer.rb:28
Looks like you're trying to call mp3fixer.rb from the shell. You can't do that. Instead invoke mp3fix.rb, which is the command line tool used by mp3fixer. "ruby mp3fix.rb --help"
yes i didn't know how to invoke the script. First time using ruby :) Now the script works, but can't fix my file :( "Mp3Fix did not find any defects." It's strange because amarok shows two lengths, once is correct one wrong. Look here: http://adrian.kicks-ass.net/stuff/mp3fixer.jpg If you want I can send you the file. It's ok because its the band of my friend and its not the finished version of the song yet. :) Amarok
yes i didn't know how to invoke the script. First time using ruby :) Now the script works, but can't fix my file :( "Mp3Fix did not find any defects." It's strange because amarok shows two lengths, once is correct one wrong. Look here: http://adrian.kicks-ass.net/stuff/mp3fixer.jpg If you want I can send you the file. It's ok because its the band of my friend and its not the finished version of the song yet. :) Amarok
OK, send it to me, I'll have a look.
ok I just send an email to you. Thanks for looking into it.
I try "ruby1.8" without any further options, is that correct? Well, nothing happens: "dirtbag666@DEBIAN:~$ ruby1.8 " Absolutely nothing.
No, the name of the program is "ruby".
"dirtbag666@DEBIAN:~$ ruby bash: ruby: command not found" Mh!
I tried cp /usr/bin/ruby1.8 /usr/bin/ruby , now it's possible to activate the script in scripts managment. Also, I get a "Added XING header" message, when I try to fix an MP3 file, but unfortunately, the song's lenght is still not correct :-/
Trying to activate the script I get this: "Das Skript "mp3fixer.rb" beendete mit dem Fehlerkode: 127 /usr/bin/env: ruby: Datei oder Verzeichnis nicht gefunden" in English: The script "mp3fixer.rb" quitted with the error code: 127 /usr/bin/env: ruby: File or directory not found" I use amaroK 1.3.7 and have ruby1.8 installed on my Debian unstable.
Well this certainly sounds strange. Can you start ruby from the shell?
When I try to use mp3fixer I get this error code /home/myuser/.kde/share/apps/amarok/scripts/mp3fixer/mp3fix.rb:79: undefined method `extname' for File:Class (NameError) /home/myuser/.kde/share/apps/amarok/scripts/mp3fixer/mp3fixer.rb:57: undefined method `success?' for 256:Fixnum (NameError) from /home/myuser/.kde/share/apps/amarok/scripts/mp3fixer/mp3fixer.rb:45:in `each' How do I fix this? My system is Debian 3.1 / KDE 3.3.2 Thanks :)
Sounds like your Ruby is too old. You need Ruby 1.8. Let me know if upgrading helped.
Thanks Markey, as always you were right on target. I updated ruby and everything works great. I remember when I first started using amaroK. My goodness as it evolved. You and your team have taken this app to amazing levels. Now if only I can convince you to add a mixing audio preview for DJing (for audio cards with hardware mixing). You will comply. Resistance is futile.... :)
Hi. After applying the fix to a lot of newly ripped CDs with wrong length, this script fixes it. But when I try to seek in the file afterwords, it just starts at the beginning of the file no matter how far out I drag the search-bar..