PDA

View Full Version : Audio sync, constant or gradual


eng3
28th May 2003, 18:22
I am capturing video using a TV Tuner and the audio is always out of sync.
Sometimes onlong encodings, it seems like the audio is more off at the end than the beginning.
Some times it seems like it is constant.

Is this a random thing? If so, it would be pretty impossible to try to fix it.

I have noticed that if I capture using MPEG1 or MPEG2 using the TV Tuner's on board hardware for compression, the audio is always in sync.

dar1us
29th May 2003, 01:06
This applies to ANYONE with sync problems

You may want to read questions 21 onwards in BaronVlads FAQ which is sticky in capturing

It is something that really cant be avioided, best ways to avoid it is by getting higherquality, more stable hardware. There are ways to counter act the problems, but no way to regain lost data, read on.

What is actually going?

Well, with the DivX, it is entirely relying on your CPU to do ALL the encoding, this means that if your CPU gets to 100% load on encoding, it has nothing else to do BUT drop frames, in this case, the audio keeps on going at whatever pace (44kHz probably). The video frames are dropped, so you will get possibly (example) 1000 video frames, 1050 (I know it doesn't work like that in audio, but you get the idea). This means that by the end of the recording, the audio is two seconds BEHIND the video.

Keeping Sync

There ARE ways to get round these problems. If capturing at 720x576 uses 80% load, than surely 352,288 (quater number of pixels) will use 20% CPU. Yes, basically. More annoying, even though you are not using your whole CPU to do the encoding, suddenly, your Kernel may be used at 100% and a frame will get dropped, this may be because you have minimized a window or recieved an instant message, anything that trivial.

It is suggested that when capturing, you leave the computer well alone, this will avoid hickups like this.

Other Codecs

Some codecs require more CPU than others, for instance, DivX5 uses more than HuffYUV, even at the same resoloution. HufffYUV is probably the most popular codec to capture in as it is 'Lossless', this means that in the processing of capturing, no quality is lost. This is good as ending results are better looking. For me, at 720x576, my CPU uses only (on average) 13%, though it absoloutly kills your hard-disk. XVID or MJPEG on the otherhand, will use a lot more CPU, but less chance of dropping frames due to your hard-disk not being able to keep up.

Colourspaces

You can try changing the colourspace used, RGB24 takes up more space/second than YUV2. This means that hard-drive activity is less, leading to less dropped frames.

Keeping the audio in sync, Even when there a dropped video frames

Sorry if I have this wrong, but a niftly little modder of the ever popular VirtualDub, called VirtualDub_sync. What this does is dynamically resample the audio so it stays in sync with the video. If a video frame is dropped, the audiorate is halved and subsequently stretched over videoframes to keep it in sync.

Fixing already captured video

If you have already captured video and it is out of sync, you can use the directstream feature of virtualdub, and find out the adjusted framerate so that audio and video durations are the same. You can then then take this framerate and use AVIRate to adjust the framerate of your file. This may fix it but maybe not. You can also play around with the interleaving options of VirtualDub. Probably the best place to start is to try ofsetting the audio stream. Save it using directstream copy in VirtualDub.


dar1us

eng3
29th May 2003, 01:30
Well, it I usually do not drop any frames even when encoding to divx but its still off sync.

if there is just a delay, I can easily fix the problem.
If its the audio gradually becomes more and more out of sync (at a constant rate), then I can use cool edit and fix it.
If its amount it is off sync varies randomly, then I can't fix it.

VirtualVCR has a feature that "resamples audio" dynamiclly, but it does not work for me. I think this may be because my TV Tuner uses the CX23880. Thats the reason I use VirtualVCR, because it doesn't work in Virtualdub.