I've been trying to convert avi source to mp4.
I used x264, vlc, and mp4box.
The problem is the extracted audio is shorter than the video.
The video's length is 00:57:38.140, and the audio is 00:57:37.312.
After muxing them, the sync is not in order.
The source file has no such problem. The sync is perfect.
The difference between the source and the extracted audio is
that the source audio track has some empty space at the beginning, but the extracted audio doesn't.
Is there a way to extract audio including empty space just like the source track?
+ Reply to Thread
Results 1 to 6 of 6
-
Last edited by IWB; 21st Dec 2014 at 04:02.
-
Thanks, Baldrick.
Adding silence is a solution to my question.
I tried that way already, but failed. I simply thought that the needed silence was 828 ms.
But It turned out wrong.
By the way, when I encoded the same source with Handbrake, the result was perfect.
Interesting... I checked out the Handbrake's log file and found this,
"sync: adding 474 ms of silence to audio 0x1 start 45626, next 2880"
The necessary silence was 474 ms, not 828 ms.
Handbrake added automatically the correct silence to the audio.
Accorddingly, I tried manually again, added 474 ms to the extracted audio with audacity.
of course the audio duration is still shorter than the video.
anyway muxed them, and the final output, mp4 synchronized well.
But how can I figure out the needed silence length when I convert manually?
I think it's hard to know, so I wondered there is a way to extract audio including silence. -
MediaInfo reports any audio delay. You might need to use View/HTML mode, but if there's an audio delay it's displayed as "delay relative to video" in the audio section. All muxing programs should allow you to apply the same audio delay when muxing. Audio and video streams aren't always exactly the same length so in itself it's not indicative of sync problems.
"sync: adding 474 ms of silence to audio 0x1 start 45626, next 2880"
Because MP4 sucks so hard, I use MKV. You can re-encode the video, open it with MKVMergeGUI, add the original AVI, de-select the original video stream and save the rest as an MKV. Any audio delays or gaps in the source AVI should be retained in the output MKV.
Sometimes AVI audio can contain non-audio data that effectively means it has gaps. MKVMergeGUI will apply an audio delay to account for any non-audio data in the beginning of MP3s. I think it only reports any further non-audio data it skips but for some reason it doesn't compensate for it. That's not overly common though.
MP4Box may be able to mux in a similar fashion to MKVMergeGUI in respect to opening multiple file types, but I don't use it much. -
Maybe there was silence at the end, as well as at the beginning.
But how can I figure out the needed silence length when I convert manually?
But since you downloaded the AVI to begin with, and since there are a lot of idiots out there uploading stuff, you often get what you pay for.
I think it's hard to know, so I wondered there is a way to extract audio including silence. -
eac3to will replace gaps with silence when demuxing, but I don't think it supports AVI. I tend to use MKVMergeGUI to open the AVI and remux it as an MKV as I described earlier then extract with eac3to. The downside there is the HD Streams Extractor (the eac3to GUI I use) tends to have a meltdown if the video within is an unsupported type, so first I'd run a quick and dirty x264 encode on the video, open that with MKVMergeGUI, add the AVI, deselect the original video, save that as an MKV, then finally it can be opened with the HD Streams Extractor. It's a bit convoluted, but tends to work when nothing else does. Fortunately, gaps in AVI audio doesn't seem to be a common problem.
As IWB discovered, Handbrake tends to be fairly clever. If nothing else works you could always convert the AVI with Handbrake and extract the audio from it's output file if need be.