Celeb Glow
news | March 16, 2026

FFmpeg convert video w/ dropped frames, out of sync

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.

7

2 Answers

It may have dropped frames if they were duplicates, if the source plays fine then your problem is more likely related to the fact that AVI containers don't handle VBR encoded formats very well (h264 in particular doesn't play well with AVI). I'd recommend starting by dumping the video to an uncompressed AVI for testing as it's the most consistent format to encode from

ffmpeg -i input.avi -acodec copy -vcodec rawvideo output.avi

Then, assuming that plays in sync you should try doing a straight codec copy and remux the source into a different format, i.e.:

ffmpeg -i input.avi -acodec copy -vcodec copy output.mkv

MKV will usually handle just about anything you stuff in it without a problem. I even hide some encrypted zip files in various mkv videos on my computer since you can encode file attachments in MKVs. So if either of that works without sync issues then try the same thing but re-encode the video or audio, but only one or the other to start and keep the container format consisten so you know where the issue lies. i.e.:

ffmpeg -i input.avi -acodec copy -vcodec libx264 output.mkv

or

ffmpeg -i input.avi -acodec libmp3lame -vcodec copy output.mkv

Try to make each test conversion as simple as possible, i.e. don't change bitrate/sample rate, use the example parameters I listed first. After each one you'll be one step closer to knowing exactly what you can and can't do. If you have to have h.264 I'd recommend going with an mp4 container as it's far more compatible than avi, on the other hand if the requirement is an avi container then I'd recommend wmv3 or msvideo1 for video as they would be the most likely to encode properly.

3

Almost always, when audio and video are out of sync and difference between the two get progressively worse over the course of the movie, especially after a conversion, the issue is one where the audio and video components were of a different length. As was observed in this instance, this happened because video frames were getting dropped, but the audio was relatively untouched during the conversion.

At times like this, it is best to first check the source movie to ensure that the audio was indeed in sync. If it is, then demux the movie, and deal with the video and audio components separately.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy