45

My collection contains some MP3s which have some glitches like:

  • displaying the wrong duration on loading
  • minor jumps
  • suddenly ending despite the duration claims another minute remaining
  • noise

I'm looking for a tool that can detect as many of these glitches as possible and fix those that can be fixed (obviously e.g. noise can not simply be eliminated in most cases).

Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400

4 Answers4

44

The command-line tool mp3val makes quick work of scanning for, and optionally repairing, structural defects in mp3 files. I try to run it over pretty much every file in my collection, on the "can't hurt" principle. It identifies amazing numbers of ostensibly-good files with defects ranging from inconsequential to severe.

mp3val is especially good at recognizing and correcting header deficiencies, such as lack of VBR headers in a VBR file (the source of most wrong-duration and seeking issues). But it will also clear out garbage/corrupted audio frame data, unusable cruft that some players may handle less than elegantly if it's left in the file.

It can even be told to run over an entire directory of mp3's, repairing only those files it finds problems with, keeping backups (or optionally not), preserving timestamps (optionally), and logging the session to a text file (optionally).

And it's free and open source! (The link is to its sourceforge project.)

EDIT: One last thing I forgot to mention. "But mp3val hasn't been updated since 2009!!", I hear you cry. That's very true! It's been working just fine since 2009, and hasn't needed an update. (After all, it's not like the MP3 file format has changed any in the past 2 years!)

FeRD
  • 1,394
11

I assumed you already tried the first option on google ...? Also a perl script, mp3checker, that might be useful.

Edit:

As for repairing your tracks might give MP3 Diags(links to a lifehacker article) a look.

John
  • 1,215
5

mpck works on Windows and GNU / Linux.

Home page: http://checkmate.gissen.nl/

It detects bad frames and generates optional reports.
There is a GUI frontend for windows too.

mpck 0.19 - checks a MP3 file for errors

Usage: mpck [OPTION]... [FILE]...

Verbosity:
   -v, --verbose        print some extra info
   -q, --quiet          print only Ok or Bad per file
   -B, --badonly        only report bad files
Other options:
   -R, --recursive      check directories recursively
   -e, --extention=EXT  only check files ending on .EXT
   -r                   short for -R -e mp3
   -m, --maxname=NUM    report bad for filenames which exceed NUM characters
   -n, --namecheck      check for strange characters in the filename
   -x, --xmloutput      output results in XML
   -h, --help           print this help, then exit
   -V, --version        print version information

Update:

This program seems to be fully capable of handling utf-8 file names, although I haven't tried japanese, chinese or more exotic glyphs.

Gentoo (UTF-8)

$ mpck -r 2000\ -\ Завтрак\ на\ траве\ \(USA\)/  | grep SUM
SUMMARY: 2000 - Завтрак на траве (USA)//04-ja-sbrasyvaju-kozhu.mp3
SUMMARY: 2000 - Завтрак на траве (USA)//07-tak-vot-kakaja-ty-demo.mp3
SUMMARY: 2000 - Завтрак на траве (USA)//09-evrej-i-goj.mp3
SUMMARY: 2000 - Завтрак на траве (USA)//06-teplyj-dozhd'-demo.mp3
SUMMARY: 2000 - Завтрак на траве (USA)//01-vse-napominaet-o-tebe.mp3
SUMMARY: 2000 - Завтрак на траве (USA)//02-marsh-novoselov--sf-unplugged.mp3
SUMMARY: 2000 - Завтрак на траве (USA)//05-rubaha.mp3
SUMMARY: 2000 - Завтрак на траве (USA)//03-kalifornia-love.mp3

Cygwin with UTF-8 locale (japanese locale in windows)
The native windows binary is not aware of cygwin so I had to convert the output.

$ mpck.exe -r "2000 - Завтрак на траве (USA)" | grep 'SUM' | 
       iconv -f CP932 -t UTF-8
SUMMARY: 2000 - Завтрак на траве (USA)\04-ja-sbrasyvaju-kozhu.mp3          
SUMMARY: 2000 - Завтрак на траве (USA)\07-tak-vot-kakaja-ty-demo.mp3       
SUMMARY: 2000 - Завтрак на траве (USA)\09-evrej-i-goj.mp3                  
SUMMARY: 2000 - Завтрак на траве (USA)\06-teplyj-dozhd'-demo.mp3          
SUMMARY: 2000 - Завтрак на траве (USA)\01-vse-napominaet-o-tebe.mp3        
SUMMARY: 2000 - Завтрак на траве (USA)\02-marsh-novoselov--sf-unplugged.mp3
SUMMARY: 2000 - Завтрак на траве (USA)\05-rubaha.mp3                     
SUMMARY: 2000 - Завтрак на траве (USA)\03-kalifornia-love.mp3            
3

Simpler is to use ffmpeg to copy the file from the one with the faulty duration in its ID3 tag. This causes it to write the correct information.

ffmpeg -i "audio.mp3" -acodec copy "audio_fixed.mp3"

Because it uses copy it takes a fraction of the time the original encoding takes. This is hardly noticeable with a song, but you really appreciate it with a 7 hour audiobook. After re-encoding, the ID3 tags now have the correct information.