Fixing Variable Bit Rate MP3’s With vbrfix

Some MP3 encoders fail to create the proper file headers when encoding variable bit rate MP3 files. When that happens, the song length displayed will often be be incorrect when playing the song back. One of the ways this can be handled is by adding a Xing header to the MP3 file. One tool that’s available on Linux to do this is vbrfix.

To install vbrfix in Ubuntu, first make sure that the universe repository is enabled in your software sources. Then you can install it through one of the graphical package managers, or from the command line with:

[term]sudo apt-get install vbrfix[/term]

 

vbrfix is a command line tool. To use it, open a terminal window and navigate to the directory containing the files that you want to fix. Then, issue the command:

[term]vbrfix in-file.mp3 out-file.mp3[/term]

 

Where in-file.mp3 is the file to be fixed and out-file.mp3 is the fixed version of that file. You can also allow it to overwrite the old file with the newer, fixed version. Simply use the same file name for output as you use for input.

[term]vbrfix file-name.mp3 file-name.mp3[/term]

 

Now, if you would like to fix and overwrite all of the MP3 files in your working directory, you can use a loop like this. Note: this assumes your file extensions are all in lower case (.mp3).

[term]for i in *.mp3; do vbrfix $i $i; done[/term]

 

I’ve never had a problem with vbrfix, but you might consider first copying your files to another directory make sure you don’t screw up your original files.

To avoid needing a tool like this in the future, make sure to use an encoder that writes the Xing header. Gstreamer can do this if you include xingmux in the pipeline. Here’s a script I wrote to batch convert audio files to MP3 using Gstreamer.

7 thoughts on “Fixing Variable Bit Rate MP3’s With vbrfix

  1. Jake

    @Tobea: put the {} in quotes, or it will fail with path and file names that contain spaces:

    find . -type f -name ‘*.mp3’ -exec vbrfix ‘{}’ ‘{}’ \;

    Reply
  2. Topea

    how to scan in sub directories? something like this “find -type f -name ‘*.mp3′” but to scan all mp3 files

    Reply
  3. Ben

    So your saying I the command I should run to fix “Shine On You Crazy Diamond Parts I-V” is (without the brackets) [vbrfix “Shine On You Crazy Diamond Parts I-V.mp3” “Shine On You Crazy Diamond Parts I-V.mp3”]? I keep getting an error saying “Failed to open input file” when I do that.

    Reply
  4. Cutlesnap

    Thank you, this fixed my mp3s!

    They had spaces in their names though, so I changed the command to:
    for i in *.mp3; do vbrfix “$i” “$i”; done

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.