Ripped mp3 files show wrong track lengths

I have seen this problem both when using Banshee and Sound Juicer. I'm using Ubuntu 12.04 on a Thinkpad 14". I'm not sure about the make of my internal CD drive, but would be glad to provide you with that information if someone tells me how to. I have not had access to an external CD drive so that I could tell if the problem is my internal CD drive.

Anyway, the problem: The mp3 files I have ripped show wrong lengths. For example when I ripped Peacebone by Animal Collective, which's length is 5:13, the file was 25 minutes long, according to my phone and banshee. The players skip to the next song before playing the whole 25 minutes. However, I'm not comfortable not knowing if I'm listening to the whole thing or the real length of the song.

This far the problem has disappeared on a second rip, although the file lengths are still occasionally a few seconds longer than they're supposed to be.


Starting around Ubuntu 12.04, when you rip CDs in Ubuntu using Rhythmbox or Sound Juicer the default settings will create VBR MP3s, but the VBR headers don't get added, so just about any program you open the MP3s with will show the incorrect track length, including the default music player (Rhythmbox) and the default file manager (Nautilus).

The easiest solution is to add the VBR header to the MP3s after ripping them:

  1. Install vbrfix by running this command in a terminal:

    sudo apt-get install vbrfix
    
  2. Now CD to the folder where the mp3s are that you need to fix:

    cd /path/to/mp3s
    
  3. Run this command to add the VBR headers to the mp3s:

    find . -type f -iname '*.mp3' -exec vbrfix {} {} \;
    
  4. Vbrfix seems to leave behind a couple of temporary files, so clean them up:

    rm vbrfix.log vbrfix.tmp
    

An alternative solution is to change the default preset so that the CDs are ripped as CBR instead of VBR MP3s. There's a pretty good explanation here: https://askubuntu.com/a/154933/18665

A profile like this ought to do the trick (change the bit rate as desired):

[mp3-cbr]
name=lamemp3enc
target=bitrate
bitrate=192
cbr=true
encoding-engine-quality=high
mono=false

As with any bug, if you're experiencing this problem I'd highly recommend you go to the bug report and mark that it affects you (near the top left), so that it gets more attention. The bug report is here: Rhythmbox does not add VBR headers when ripping CDs to MP3


From my experience this problem occurs when ID3 tags are invalid. You could try to delete all ID3 tags from the given files and then rewrite them. I recommend mutagen for this, it's a metadata manipulation library with some useful utilites.

First install mutagen

sudo apt-get install python-mutagen

Now go to a folder with some problematic MP3 file and run mid3v2 on it:

mid3v2 --delete-all your_file.mp3

This will remove all metadata from a given file, which means no title, no artist, no album cover, but the file should display correct length.

You can repopulate metadata using e.g. Picard, which is available in Ubuntu as picard package.

Edit: There's also MP3 Diags application which should be able to fix VBR headers and some other problems with MP3 files. It's available in Ubuntu as mp3diags (or from Ubuntu Software Center)

Another, more specific, solution is VBRFix – console version (without Qt GUI) is available in vbrfix package. If you want GUI, you'll probably have to compile it yourself.