How to "reencode" mp3 files
While I do not know specifically whether additional options would be needed to fix the issue you mention, ffmpeg is
a complete, cross-platform solution to record, convert and stream audio and video.
It is the swiss-army knife for audio and video. Re-encoding your files should be as easy as
$ ffmpeg -i oldfile.mp3 newfile.mp3
ffmpeg
is in the repositories of most major distributions or it can be downloaded from their website.
It does not answer the question in your title, but maybe there's a chance to fix the files without reencoding. For example, one common issue with incorrect lengths of MP3 files are files with variable bit rate that are not properly marked as having a variable bit rate (and programs like rhythmbox treating them as if they had a constant one). The tool vbrfix can fix those files. Another useful tool to check the MP3 file is mp3check, it also has options like --fix-headers
that might repair the files (make backups of the files first!).
It is possible to do it with lame
and carry over the id3 tags (found it here).
find . -type f -iname "*.mp3" | while read file
do
mv "$file" "${file}.old" && \
lame --mp3input -q 0 -b 192 --resample 44.1 "${file}.old" "$file" && \
id3cp "${file}.old" "$file"
done
See more conversion scripts I have writtten here: https://github.com/sid-the-sloth/conversion-scripts