How can I fix incorrect mp3 duration?
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)
Related videos on Youtube
Comments
-
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 over 10 yearsThis 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 evenmediainfo
shows the duration from the first file rather than the combined. -
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 over 10 yearsWhy 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 over 10 years
ffmpeg
withconcat
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 over 6 yearshelped when Windows media player showed wrong mp3 file duration
-
Pierpaolo Cira about 6 yearsPerfect solution, works also if the wrong mp3 file has been created by ffmpeg itself!
-
Noldorin about 6 yearsThis actually worked for me, when the
mp3val
andmp3check
solutions didn't. (Just to be sure, it doesn't re-encode, right?) -
Alcaro about 6 yearsWith -acodec copy, it doesn't reencode. If you want to verify, try with and without it and check how fast it goes.
-
digitaltoast about 5 yearsWARNING 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