Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's a similar question for windows:

Tool to fix video that's out of sync with audio?

I'm hoping to solve this problem on a Mac.

I've tried Handbrake and Avidemux (the latter seems to have an option -- "shift" -- to fix it but it doesn't play the audio at all so I can't tell if it's doing anything!).

share|improve this question
Is the goal watching it or saving it to a device? There are easy options if it's just to watch it on your lappy. – nerdwaller Oct 31 '12 at 2:17
Ah, yes, goal is saving it (to youtube, ultimately). – dreeves Oct 31 '12 at 2:38
up vote 5 down vote accepted

Get yourself a copy of FFmpeg. See the bottom of this post on how to do that.

Whether the video lags behind the audio or vice-versa, it doesn't really matter. The basic command is as follows. We will pass the input twice, as can be seen by two -i options, then delay one input, and merge them back together.

ffmpeg -i in.flv -itsoffset offset -i in.flv -map 1:0 -map 0:1 -c copy out.flv

Here, offset is the delay in seconds, e.g. 1.5 or 0.35. This value has to be positive, so if your audio is lagging behind the video, we will have to offset the video. This is shown in the above example. Similarly, if the video is lagging behind the audio, we will have to offset the audio.

So, how do you choose whether to delay audio or video? Well, since we've delayed the whole in.flv, we'll just pick the audio or video streams and merge them with the original audio or video streams. This is done in the -map options.

Basically, map has two numbers. The one before the colon specifies the input file number (starting at 0), and the second number specifies the input file stream (also starting at 0).

So, to delay the audio, use the following two options:

  • -map 1:0 means: Take the first stream from the second input file, (video from the original file)
  • -map 0:1 means: Take the second stream from the first input file (audio from the delayed file)

Turn it around if you have to delay your video:

  • -map 0:0 means: Take the first stream from the first input file (video from the delayed file)
  • -map 1:1 means: Take the second stream from the second input file (audio from the original file)

Finally -c copy will simply tell FFmpeg to copy the video and audio bitstreams. This means that there will be no encoding process. This makes the command ultra-fast and you won't even lose any quality in the process. If, however, you run into synchronization errors, then you should leave out -c copyand let FFmpeg re-encode the input.

You can get the latest stable FFmpeg version through Homebrew.

  • Open a Terminal and enter:

    ruby -e "$(curl -fsSkL"
  • See the installation requirements as well. You have to install the Commandline Tools for Xcode if you haven't. You will need an Apple ID for that.

  • Once Homebrew is installed, install FFmpeg:

    brew install ffmpeg
  • Once that is done, we can use FFmpeg to fix your video.

share|improve this answer
Worked! Thank you so much! – dreeves Oct 31 '12 at 22:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .