Fixing Variable Bit Rate MP3′s With vbrfix

March 4, 2012 by
Filed under: command line, HowTo, linux, mp3, Ubuntu 

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:

sudo apt-get install vbrfix


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:

Affiliate Link
vbrfix in-file.mp3 out-file.mp3


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.

vbrfix file-name.mp3 file-name.mp3


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).

for i in *.mp3; do vbrfix $i $i; done


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 Responses to “Fixing Variable Bit Rate MP3′s With vbrfix”

  1. Jake says:

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

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

  2. Topea says:

    Got it to scan for all mp3s in directory and sub directories use > find . -name '*.mp3' -exec vbrfix {} {} \;

  3. Topea says:

    how to scan in sub directories? something like this "find -type f -name '*.mp3'" but to scan all mp3 files

  4. Ben says:

    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.

  5. Cutlesnap says:

    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

  6. Surely there's a typo in the third code example above? It uses "fixvbr" instead of "vbrfix" as a command.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>