How can I fix incorrect mp3 duration?

30,700

Solution 1

MP3 Diags can fix incorrect durations (and other errors). It is open source and in the repositories. It is a GUI Tool.

Installation

sudo apt-get install mp3diags mp3diags-doc

Another option is MP3val, which can be used either via commandline or via GUI:

Installation

sudo apt-get install mp3val

Usage example

mp3val damaged.mp3 -f -t

-f: fix errors, -t: keep original timestamp

Solution 2

If you don't want to install anything new, try with ffmpeg:

ffmpeg -i file_orig.mp3 -acodec copy file_fixed.mp3

Solution 3

Aside from the VBR headers not matching the actual audio (which you would use mp3val to correct, as mentioned in the other answer), another reason this can be caused is by an MP3 file having ID3 tag that has an incorrect value for the TLEN tag. You can fix this using the mid3v2 tool from the mutagen package to remove the tag (apparently its optional):

$ mid3v2 --delete-frames=TLEN filename.mp3

The music player Quodlibet also has a convenient "Fix MP3 Duration" plugin you can use to do this.

(Taken from the Quodlibet FAQ: http://quodlibet.readthedocs.org/en/latest/guide/faq.html)

Share:
30,700

Related videos on Youtube

Jason Southwell
Author by

Jason Southwell

See rolandixor.pro for more about me.

Updated on September 18, 2022

Comments

  • Jason Southwell
    Jason Southwell over 1 year

    I have a number of songs in my Music library that display incorrect duration values, and so play only partially in Clementine. In Banshee and some other players they show different duration values and sometimes play the full song.

    Is there a way to fix this without having to "re-encode" the song?

  • blockloop
    blockloop over 10 years
    This worked for me. I use cat to combine audiobook parts into one file (cat 1.mp3 2.mp3 > out.mp3) and that works great for playback but almost every player gets wacky with the timestamps and even mediainfo shows the duration from the first file rather than the combined.
  • phoibos
    phoibos over 10 years
    cat is less than ideal for tasks like combining mp3s. A better way: http://superuser.com/questions/314239/how-to-join-merge-many‌​-mp3-files
  • blockloop
    blockloop over 10 years
    Why do you think that? MP3 files aren't much more than raw streams and they're almost the perfect candidate for cat aside from trivial side effects solved with a simple reassessment of Xing header data. Even without the mp3val the files still play in every player I've sent them through. cat is extremely efficient and MUCH faster than re-encoding with ffmpeg. Even with the added mp3val command.
  • phoibos
    phoibos over 10 years
    ffmpeg with concat and -acodec copy does not re-encode - it just copies the streams (so it's fast), but creates a proper file in the first place (without useless header & tag data appearing multiple times in the resulting files).
  • Mantas D
    Mantas D over 6 years
    helped when Windows media player showed wrong mp3 file duration
  • Pierpaolo Cira
    Pierpaolo Cira about 6 years
    Perfect solution, works also if the wrong mp3 file has been created by ffmpeg itself!
  • Noldorin
    Noldorin about 6 years
    This actually worked for me, when the mp3val and mp3check solutions didn't. (Just to be sure, it doesn't re-encode, right?)
  • Alcaro
    Alcaro about 6 years
    With -acodec copy, it doesn't reencode. If you want to verify, try with and without it and check how fast it goes.
  • digitaltoast
    digitaltoast about 5 years
    WARNING If you have id3v2 tags, cover art etc, be extremely aware of these issues (I learnt the hard way) bugs.launchpad.net/ubuntu/+source/mp3check/+bug/592775 bugs.launchpad.net/ubuntu/+source/mp3check/+bug/1348223