Wednesday, October 31, 2012

osx - Fix an m4v video that has lagging audio (audio and video out ...

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 raw.github.com/mxcl/homebrew/go)" 
  • 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.

Source: http://superuser.com/questions/496653/fix-an-m4v-video-that-has-lagging-audio-audio-and-video-out-of-sync

jonestown john dillinger carlos zambrano clemson pellet gun clay aiken zambrano

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.