Source i (link to git-repo or to original if based on someone elses unmodified work):

Add the source-code for this project on opencode.net

1
Become a Fan
5.0

Description:
Mp3Fixer is an amaroK Script for repairing various defects in MP3 files, for instance files which display a bogus track length in your audio player.

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
Last changelog:

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

janet

I really wish this would be available for Amarok 2... Is there a chance to add something like this?

winch

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.

vitaly

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. :(

esa

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.

Ekardnam

Works perfectly for me, thanks for the script.

ramvi

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)

markey

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

travise

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.

markey

That's strange.Can you send me one of these files? markey@web.de

sektion31

.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

markey

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"

sektion31

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

sektion31

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

markey

OK, send it to me, I'll have a look.

sektion31

ok I just send an email to you. Thanks for looking into it.

dirtbag666

I try "ruby1.8" without any further options, is that correct? Well, nothing happens: "dirtbag666@DEBIAN:~$ ruby1.8 " Absolutely nothing.

markey

No, the name of the program is "ruby".

dirtbag666

"dirtbag666@DEBIAN:~$ ruby bash: ruby: command not found" Mh!

dirtbag666

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 :-/

dirtbag666

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.

markey

Well this certainly sounds strange. Can you start ruby from the shell?

BorgQueen

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 :)

markey

Sounds like your Ruby is too old. You need Ruby 1.8. Let me know if upgrading helped.

BorgQueen

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.... :)

Skrot

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..

Pling
0 Affiliates
Details
license
version 0.9.4
updated
added
downloads 24h 0
mediaviews 24h 0
pageviews 24h 0

Other Amarok 1.x Scripts:

Gnome Play Video in Totem
mwheatland
last update date: 18 years ago

Score 5.0

editLyrics-gnome
ZeeD
last update date: 19 years ago

Score 5.0

amarok Alarm
aroth
last update date: 16 years ago

Score 5.0

amaroK Web Collection V xmms
pti-jean
last update date: 16 years ago

Score 5.0

SongLogger
lucatnt
last update date: 17 years ago

Score 5.0

amaroK Web Collection
pti-jean
last update date: 16 years ago

Score 5.0



System Tags