Log in

View Full Version : Fixing non-linear A/V sync problem


^rooker
4th December 2005, 12:00
IMPORTANT:
I'd actually like to submit this as a regular guide, but I don't know how (can't find info), so I post it here - please tell me if that's wrong.
-----------------------------------

[PROBLEM]
When recording very long video material from analog source (e.g. VCR), it might happen that audio/video asynchronism are not continuous due to heavy signal distortion (e.g. broken tape, switching channel on VCR, ...).

Here's a "graphical" example of what I mean:

Part 1 Part 2
Video |---------------V----------X--V------------------|
Audio |---------------A----------X-----A---------------|
FrameRate: 24.995 fps ??? fps
Audio Offset: 0 msec ??? msec
Duration: 10,002 min. <not important>

"X" ... Distortion
"V" ... video of event used to adjust audio sync. (e.g. lips speaking)
"A" ... audio of event used to adjust audio sync. (e.g. the corresponding utterance)

In this example Part 1 is AV-sync at 24.995 fps and an audio offset of 0 msec, but with those values, Part 2 is not.
In order to synchronise Part 2, a different combination of audio-offset AND framerate is required.

In practice, this is a real hazzle, because without the right starting position (offset) of the audio, you can't even start to find the right framerate.

This means: At an assumed framerate, you could try to adjust the offset to match the video at a certain event (e.g. a speaker utterance) to have a starting point, but if the framerate was not guessed correctly, you will see that the video is either too fast or too slow:


Part 1 Part 2
Video |---------------V----------X--V------------------|
Audio |---------------A----------X-----A---------------|

FrameRate: 24.995 fps
Audio Offset: -12000 msec
Duration of Part1: 10,002 mins

NOTE: Audio and video of the event in Part 2 are now matching, but Part 1 is now out of sync.


When you try to re-adjust the framerate now, all frames before your sync'ed event will be affected, too - so you've lost your syncing point and can start all over:


Part 1 Part 2
Video |-----------------V------------X-----V-------------------|
Audio |---------------A----------X-----A---------------|

FrameRate: 24.3 fps
Audio Offset: -12000 msec
Duration of Part 1: 10,288 mins

Because Part 1's video duration is now longer, Part 2 is directly affected.


Really great, huh? :?

^rooker
4th December 2005, 12:07
[SOLUTION]
In order to fix this problem in reasonable time, leave the framerate original (e.g. 25) and ONLY adjust the audio offset to have the start of Part 2 in-sync.

You should choose an event as close to "X" as possible.


Part 1 Part 2
Video |---------------V----------X-V--------------------|
Audio |---------------A----------X---A------------------|
FrameRate: 25 fps
Audio Offset: -11300 msec
Duration of Part1: 10,000 mins



Now throw away everything before your sync'ed event and export it (direct stream copy of audio and video) to a new file.
Since the resulting file is synchronous at its start, you only have to adjust the framerate properly and you're done. :idea:


Part 2
Video |X-V--------------------|
Audio |--A------------------|
FrameRate: 25 fps
Audio Offset: -11300 msec



...the drawback of this solution is, that you must process Part 1 and Part 2 separately and merge them back together at the end.

mod
4th December 2005, 12:23
Hi.
Is't more simple to change audio sampling frequency during capture to get always a perfect match with video?
I use VDub and this operation is automatic, there's no need to correct any timeshifting, because when the video and the audio loose sync the audio is resampled..
Sorry if I didn't understand what's the point.

^rooker
10th December 2005, 09:19
Certainly it's always nice to have A/V already sync'ed, but I'm just trying to help someone who has this certain kind of problem.

No matter how it happened, where it came from or whatsoever.

In my case, VirtualVCR is producing this kind of problem very often - and when I tell it to resample the audio, it produces async problems which are so non-non-non-linear that they cannot be solved at all.

(and unfortunately, my capture-card doesn't work well with VirtualDub)

mod
10th December 2005, 12:16
No matter how it happened, where it came from or whatsoever

Ok, I'm sorry I didn't get the matter.
But let's tell to people who have this problem how to avoid it in the future :)