Apply an Audio Delay when Out of Sync

Discuss about generic usage of MediaCoder.

Moderator: HuggiL

Posts: 3116
Joined: Tue Jun 23, 2009 2:45 pm
Location: Sydney, Australia

Apply an Audio Delay when Out of Sync

Post by meRobs » Thu Dec 24, 2009 11:01 am

[Updated 25 Nov 2010]
The audio in a file may be out of sync with the video for a variety of reasons. It may have occurred before you got the file, such as an FLV file downloaded from the web. It may occur during a file conversion, from one format to another.

By the way, sometimes audio may appear to be out of sync when played in MPlayer (Play button in MediaCoder), but this may just be an artefact for this player. For example, I have seen this on playing an FLV file in build 4625. The FLV played correctly in other software players and once converted to AVI or MPEG2 it was also in sync.

A common example of an out-of-sync case would be a file converted directly from a VOB file, as discussed in the post: viewtopic.php?f=17&t=8082&start=0. I am not suggesting that a VOB file will 'play' out of sync, merely that it may well be out of sync once converted. If you really must convert a VOB, it may be necessary to apply an audio delay in MediaCoder or use AviSynth (below).

Apply an Audio Delay
An attempt to apply a delay from the Time (or Sound) tab in MediaCoder will not work for some builds, such as 4582, 4640 and 4745, as indicated in the Test Report viewtopic.php?f=17&t=9611. The delay tab feature doesn't work because MediaCoder fails to copy over your entry into 'Advanced Settings', which controls the conversion.

So, if Audio Delay fails in your build, click on “Advanced Settings”, the third button from the right on the Toolbar (Fig. below).
Then, select 'Overall' and 'Audio options'. Here, you should enter a value for “Delay of audio track 1 (ms)”. To do so, select (click on) this item and an 'Apply' button with its entry panel will then appear at bottom left of the window. Enter a value (in millisec) in this panel, including a minus sign if applicable, and click Apply.

Once the conversion is done, reset the delay to zero, by selecting the item again and clicking 'Revert', at bottom right.


Copy Video
If all you wish to do is correct the audio delay, as above, yet keep all else the same, it still requires a conversion. So, to not affect the video quality, convert without re-encoding the video, by checking 'Copy Video' on the Video tab. Of course, as with audio delay, 'Copy Video' may not work in your build of MediaCoder, so, check this out in the Test Report (viewtopic.php?f=17&t=9611).
For example, I tried applying audio delays of +700 ms and –700 ms to an FLV file with MP3 audio at 64 fps. I used the settings given in section 3 of the Encoding Guide (viewtopic.php?f=17&t=9643). This gave the desired result for both delays.

Since it is possible that the conversion may have a slight effect on audio quality, it is also possible this would be avoided if the conversion had been done at a higher bitrate, say, at 96 kbps for a source at 64 kbps, with little effect on the file size.

Use of AviSynth
It seems that AviSynth, when used as the video 'Source', instead of MEncoder or FFmpeg, say, will make allowance for the 'Video delay' value in the metadata (header) of a VOB file by adding duplicates of the first frame to align the audio. I tried this in build 4625 for a conversion to MPEG2 and to DV AVI (DV Video Codec). The use of MEncoder as source maintained the 732 msec delay in the VOB, whereas, AviSynth corrected for it and all was in sync.
Other examples are in: viewtopic.php?f=17&t=8624&start=0

This is worth a try.
Have you checked out the Tips & Guides for MediaCoder? Try:
Also, get older builds at: