Repair broken MP3 files
Some application (which shall remain nameless) complained about "invalid MP3 formatted files", but gave no clue about what exactly was "invalid". The files played just fine, their ID3 tag were displayed too, so this application appeared to be overly picky about these files. Let's have a closer look:
$ file foo.mp3 foo.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer II, v1, 192 kbps, 44.1 kHz, StereoAha! Although the file was named
.mp3
it really was an mp2 file. Of course, most program can play MPEG-2 just fine, but this application refused to do so.
The ever-so-faithful lame was quick to help:
$ mv foo.{mp3,mp2} $ lame --mp2input foo.mp2 foo.mp3Also, the ID3 version said "2.3.0", which is perfectly valid but maybe there was something else wrong with these files so I needed some magic program to check (and repair) this file's ID3 tag. mid3iconv (from python-mutagen) is supposed to do just that:
$ mid3iconv -d foo.mp3 Updating foo.mp3 TPE1=Snafu TDRC=2002 TIT2=FooBar TRCK=1 TALB=Baz TCON=ElectronicNow our file looked like this:
foo.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, JntStereo...and the application was happy to process this file :-)