This is the script I'm now using:
#!/bin/bash echo "checking $1" find "$1" -name "*.mp3" | while read filename; do echo "checking $(basename "$filename")" ffmpeg_dur=$(ffmpeg -i "$filename" 2>&1 | awk -F: '($1 ~ /Duration/) ' | bc) # mp3_check_dur=$(mp3_check -a "$filename" 2>&1 | awk -F'[ :.]+' '($1 ~ /SONG_LENGTH/) ' | bc ) mp3info_dur=$(mp3info -x "$filename" 2>&1 | awk -F'[ :.]+' '($1 ~ /Length/) ' | bc ) if [[ -z $ffmpeg_dur ]] ; then # some files are so broken that ffmpeg doesn't print a length echo "ERROR (ffmpeg): $filename" else len_diff=$(( $ffmpeg_dur - $mp3_check_dur )) if [[ $len_diff -gt 0 ]] ; then echo -e "ERROR (length): $filename\t$" fi fi done
The duration reported by ffmpeg
is always longer than the one of mp3_check
and mp3info
. 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.