22 Mar 2009

MP3s with incorrect track length

An MP3 file may be broken for many reasons.  A very common error in MP3 files is incorrect track length.  Some CD ripping software, maybe due to a bug, occasionally produce MP3 files with incorrect length.  Such a file would show as having, say 2:35 as its length when opened in a media player.  But the actual length of the track might be more, say 3:15 or something.  Most modern media players like iTunes, WinAmp, Amarok, etc. handle such tracks gracefully.  However, my iPod seems to have trouble playing such files.

A quick Google search for fixing this problem doesn't show any Linux-based tool.  But the good news is that we don't need any special software for fixing this problem!  Any sound converting software would do the job.

I used soundKonverter for this.  I added the files that had this problem and converted them to same MP3 format with same bit-rate.  This forces the converting software to fully re-read the track and freshly write one.  That solves the track length issue.

If you know how audio encoding/decoding works, you might think now that this is not the correct solution for this problem.  You're right.  We might lose some audio clarity in the decoding/encoding.  If we only measure the length and fix the existing MP3 file itself it will be a lot faster.  But I don't know of any tool that does exactly this.  My approach seems to work anyway, I don't care much as long as the work is being done :)

PS: A friend suggested using a hex editor and manually writing the track length in the file.  While the idea is really interesting, I'm not doing it right now, mainly because I have several such corrupt files and I don't have the patience to fix them all by hand.

No comments:

Post a Comment