3
1
I recorded a video using Bandicam with the MJPEG encoder to get the least amount of lag. Now, I am trying to convert that massive file to a h264 avi using ffmpeg. I know there are dropped frames in the video stream...more than 100 in the first two minutes, which I assume is simply because Bandicam dropped some when it couldn't keep up. So, when I convert the file to h264, the video and audio are out of sync, and appear to be more and more out of sync as output video progresses. Here is my basic command in ffmpeg:
ffmpeg -i "C:\...\input.avi" -vcodec libx264 -q 5 -acodec libmp3lame -ar 44100 -ac 2 -b:a 128k "C:\...\output.avi"
I have tried EVERYTHING I can think of including:
-itsoffset [-]00:00:01
Tried this before and after input file. This doesn't work because as the video progresses it becomes more and more out of sync.
-async 1
Doesn't work.
-vsync 1
Doesn't work, but it does show dropped frames being duplicated.
Two inputs of same file with mapping using -map 0:0 -map 1:1
. Doesn't work.
The source plays just fine. Any ideas how to convert it with ffmpeg and keep the audio and video synced? Thanks.
The reason why the synchronization gets worse as the file progresses, is because there is an difference between the length of the video, and the length of the audio. If they were the same length, the offset would fix this. Does the original file have the same issue? You may have to demux the original manually, and convert the audio separately from the video, and then remux into the AVI. – Bon Gart – 2012-06-13T08:57:20.813
OK, I think I can do that. Is is possible that the audio 'dropped frames' as well (I know it doesn't have frames, but you get the idea)? – preahkumpii – 2012-06-13T08:58:57.093
It really depends on whether the PTS (presentation timestamps) are still correct, because only then synchronization would even work. I guess it's hard for the encoder / muxer to even realize there's a dropped frame and where to put the audio in between, so I would go with what @BonGart said and see where you can go from there. // Audio has frames too ("samples"), but I think it's unlikely there are dropped samples. – slhck – 2012-06-13T09:00:58.250
Maybe you can also post the full, uncut console output from your FFmpeg command. – slhck – 2012-06-13T09:05:02.703
Just demuxing the original and looking at the lengths in any info tool should give you a heads up.... providing the audio isn't off in the original. – Bon Gart – 2012-06-13T09:33:43.127
That was it; that is, I extracted the video and audio separately, with video
-vsync 1
set to make sure the frames were filled in. Then, I made a new file with the two separate files using-map 0:0 -map 1:0
. @Bon Gart pls put a formal answer so I can mark it answered. – preahkumpii – 2012-06-13T10:02:02.037@preahkumpii done... unless you want me to flesh the answer out more. – Bon Gart – 2012-06-13T22:19:23.837