I recently had a hard disk failure and could not rescue all my music files. Since I didn't have enough storage available to do a full backup of the disk, I tried to cp
as many tracks as possible, but now I am left with some files that end prematurely.
I already found this answer to find out "the song length" and this tool that does the same. For one broken file, I get this output:
ffmpeg -i broken.mp3 2>&1 | grep Duration
Duration: 00:04:18.14, start: 0.025057, bitrate: 92 kb/s
mp3_check -a broken.mp3 2>&1| grep SONG
SONG_LENGTH 01:43.05
So ffmpeg
seems to rely on some metadata (04:18 is the duration that is also displayed in my media player), while mp3_check
seems to actually read the whole file. I could use this to write a script that covers mp3, but:
Is there an easier solution rather than comparing ffmpeg
and mp3_check
output in order to find broken files?
How would I do this with Ogg files, where no mp3_check
is available?
Best Answer
This is the script I'm now using:
The duration reported by
ffmpeg
is always longer than the one ofmp3_check
andmp3info
. There sometimes is a 1 second difference between the latter as well.mp3info
is available as package for some linux distributions (Ubuntu, Arch, ...?),mp3_check
has to be built from source.