Log in

View Full Version : Fixing a very broken mp3 - keep same length


mrslacker
7th February 2005, 05:40
I have an mp3 track from an avi that has many errors. I can fix the mp3 with Besplit, but the resulting track length is 15 seconds shorter. As a result, there is poor sync with the video. Here is a sample of BeSplit's output near the problem area:
[01:17:27:066] Stream error : Sync found after 137 bytes
[01:17:27:154] Stream error : Sync found after 14098 bytes
[01:17:27:240] Stream error : Sync found after 25652 bytes
[01:17:27:369] Stream error : Sync found after 21029 bytes
[01:17:27:419] Stream error : Sync found after 5714 bytes
[01:17:27:531] Stream error : Sync found after 37962 bytes
[01:17:27:583] Stream error : Sync found after 14507 bytes
[01:17:34:632] Stream error : Sync found after 27460 bytes
[01:17:34:656] Stream error : Sync found after 2852 bytes
Needless to say, it's a pretty messed up source. AVIMux GUI stopped extracting at 1:17 of 1:33, and I had to use VirtualDub to demux the full track. How can I fix an mp3 in such a way that the bad frames are replaced with silence, so as to keep the original track length? Is this not a simple task, as it is with AC3 and mp2?

I can decode the original mp3 with lame.exe --decode or madplay, but the wav is still short, but only by a few seconds. Running the mp3 straight into BeSweet or ffmpeg (on the way to AC3) produces similarly shortened tracks. Note: BeSweet's "Transcoding..." time counter goes way past the actual duration to nearly 3 hours.

I think the solution is to somehow fix the mp3 by inserting silence, but I don't know how. Any suggestions?

Kurtnoise
8th February 2005, 11:02
What's happend if you play directly your avi file ?

Brother John
8th February 2005, 19:25
foobar2000 has a "fix mp3 header" function that can rebuild the whole mp3 stream, too. I never tried fixing such a badly corrupted file that way, however it might be worth a try.

mrslacker
8th February 2005, 21:48
Originally posted by Kurtnoise13
What's happend if you play directly your avi file ?

Actually, I'm not sure what happens if it plays through that spot. However, It plays in sync with the video when I seek to a point after the corruption. I can try playing through when I'm home. I suspect there will be more than a few clicks and pops with some silence. It will probably depend on whether I'm using the demuxer and decoder that gabest built into MPC or my systems DShow filters.

BTW: I LOVE BeLight! The interface is very easy on my eyes... and elegant. One thing, when I open BeLight, it remembers the sample rate as 48000 from the last time, but the command line displays as 44100. I have to select another sample rate and then go back to 48000 for the command line to reflect the GUI settings.

Kurtnoise
9th February 2005, 20:02
Originally posted by mrslacker
BTW: I LOVE BeLight! The interface is very easy on my eyes... and elegant. One thing, when I open BeLight, it remembers the sample rate as 48000 from the last time, but the command line displays as 44100. I have to select another sample rate and then go back to 48000 for the command line to reflect the GUI settings.
Which version did you use ? I think it's fixed with the last version. But I don't remember exactly. I'll check it...

mrslacker
9th February 2005, 23:29
Originally posted by Kurtnoise13
Which version did you use ? I think it's fixed with the last version. But I don't remember exactly. I'll check it...

Version 0.21 stable. Unchecking and rechecking "Sample Rate" in the SSRC area works as well. I haven't bothered to check if the output matches the command line preview or the GUI selection. I assume the displayed command line is what you have coded it to execute.

mrslacker
17th February 2005, 00:48
Originally posted by Brother John
foobar2000 has a "fix mp3 header" function that can rebuild the whole mp3 stream, too. I never tried fixing such a badly corrupted file that way, however it might be worth a try.
The resulting file is still shortened, even when using the full rebuild option. Very cool program though!

Salvaging this file will probably require silence to be manually inserted at the problem area. I don't know enough about how timekeeping is accomplished with mp3, or any audio file for that matter, to say why I can't fix (or decode) such an mp3 while preserving the same playback times. Do mp3 or riff contained files seek by sample rate or is there some kind of PTS like in mpeg? I'm not an aspiring audiophile, I'm just curious.

johnman
17th February 2005, 02:03
Originally posted by mrslacker

I don't know enough about how timekeeping is accomplished with mp3, or any audio file for that matter
i believe that an mp3 is divided up in frames, and every frame has a length of 0.026 secs.

I think if u fix the broken frames (if all are present) you would get an audio file that plays in sync, but probabely with some pops and other noise. If some frames are missing, it can only be repaired by hand obviously.

if you could somehow get a chunk of the mp3 (with an error in the middle) online....

this might help to analyse your problem