View Full Version :
AUDIO Codec for Capture in VirtualDub
mkanar
8th January 2002, 17:23
I typically capture with VirtualDub using raw PCM 44.1KHz/16 bit/Stereo for the audio capture. I turn of the 'adjust video/audio to prevent desynchronization' option in order to prevent dropped frames. It wasn't until several months ago that I realized that VirtualDub drops frames in order to maintain the synchronization. My audio capture cards capture at a relative datarate pretty close to 44.1KHz, but are always at least a little bit off of course. This causes the audio and video streams to 'slightly' differ in length. Therefore, I typically adjust the framerate of the AVI file after capture so that the video length is effectively adjusted to match the audio length.
When attempting to capture and compress the audio 'on-the-fly' using a codec such as the FHG-Radium MP3 codec (again using 44.1KHz/Stereo), the audio datarate becomes much much less accurate. For example, instead of a relative audio datarate of 44106Hz using RAW PCM, the datarate might be 43069Hz with the MP3 codec.
First question: Are there any high-quality compression codecs that are known to not have this issue?
Second Question: Does anybody have a different approach to not dropping frames while maintaining syncronization?
Thanks,
mkanar
Cart
8th January 2002, 19:00
1) I generally don't recommend compressing the audio during capture. If you want, you could try the ADPCM codec.
2) No. In different sections of the same video, the audio can be both ahead and behind the video, making it difficult to ensure synchronization. However, if your sound card is consistently ahead of or behind the video, your framerate adjusting method should work. Maybe something like dynamic audio resampling could solve the problem, but you're probably never going to notice those few dropped/duplicated frames.
-Cart
http://www.geocities.com/lukesvideo/index.html
mkanar
17th January 2002, 00:05
Yes, I've tested this with a variety of computers, capture cards, and sound cards (ranging from AC97 sound on the motherboard to SB Live! and Aureal Vortex). Each capture card is off the mark for 44.1KHz and also 48KHz although sometimes not as much. However, each sound capture (when capturing in RAW PCM) has a consistant relative datarate to the video. Put bluntly, I except that this is a problem for many users out there. In VirtualDub especially, there isn't really all that much documentation. Many users spend countless hours trying to figure out why their system can't keep up and is dropping frames when all the while it is simply virtualdub dropping frames on purpose.
I actually have two solutions. In both solutions, I click OFF the 'synchronize audio/video during capture' checkbox before capturing with VirtualDub. The first solution then is to change the framerate of the AVI file just slightly so that the length of the audio and video are the same. To determine this, load the AVI file up in VirtualDub, click on Video:Frame Rate. You will see something like 'Change so video and audio durations match (29.965fps).' Write down the fps value and close out virtualdub. Next, use the AVI frame rate adjuster utility (available from doom9 downloads of course!) to change the fps to the value that was written down. This change takes 2 seconds. So what happens when I feed a 29.965fps video to something like TMPGEnc that encodes a SVCD as 29.9706fps? I don't know; either it resamples the audio just slightly or maybe the entire SVCD clip will simply play slightly faster or slower.
The other solution is to write down the ending 'relative audio datarate' that VirtualDub lists during the capture. Say it is something like 44108 KHz. Then, open up VirtualDub, and click the 'popup extended open options' checkbox while opening the .avi file. Various selections will appear when opening the file; click on the 'Force Audio Sampling Rate to __ Hz' and place the value that was written down into the ___ blank. Finally, click 'audio', 'conversion', and select '44100 KHz.' At this time, the AVI and be written to disk as a new filename; select direct stream copy for video if you wish to keep the video stream intact and then select full processing for audio regardless. In this method, I believe that it might be possible that the audio's pitch is actually corrected to a more accurate value, assuming that the sound card is actually capturing the audio at a rate slightly scewed to the standard KHz values.
It does seem as if VirtualDub should be capable of resampling the audio during capture, at a cost in CPU power of course.
I might be off the mark here, although I've done lots of experimentation and reading up.
Comments and/or suggestions?
Thanks!
MKanar
Mark Fredrickson
17th January 2002, 17:51
I've been using AVI_IO for the last 6 months because it was the only capture program (at the time) that provided perfect audio/video synchronization. Have I been living in the dark?
I use VirtualDub for encoding to DivX but didn't know that it now provides audio/video synchronized captures. Is this new? I do remember emailing Avery requesting he add something like what Markus was doing with AVI_IO (eg. inserting/dropping frames to maintain synchronization).
I don't mind the odd inserted or dropped frame because I really can't see it. I just want exactly 29.97 framerate on all my captures because sometimes I have to join them together and VirtualDub will not append files if the framerates are even slightly different. I also want to minimize the amount of work required to capture. Trying to synchronize manually after capture has been somewhat a chore for me.
I've also been having a bit of a problem with AVI_IO and Huffyuv and would love to start using VirtualDub for captures if it worked as well as AVI_IO.
Can anyone (Hi Cart) verify that VirtualDub does synchronize audio as good as AVI_IO and whether this feature is relatively new?
Thanks,
Mark.
mkanar
18th January 2002, 05:29
VirtualDub has been able to add/drop frames for at least a good long while. In AVI_IO, when it drops a frame to keep sync, does it list a 'dropped' frame?
I'm surprised there aren't any more comments on this matter. Perhaps everyone is happy with a few lost frames? It depends somewhat on the source, but I can definately notice when a dropped frame occurs. Does anyone use a particular high-quality compression codec during capture and keep sync without loosing many/any frames?
Thanks!
MKanar
Cart
20th January 2002, 00:27
mkanar:
I don't think the dropped frames are that important. As long as they don't occur in bunches (as they shouldn't), they aren't noticeable (to most people). The problem with adjusting the audio after is that (according to Avery Lee) the sound card isn't always off by a consistent amount. This means that in certain portions of the video, the audio will be ahead, whereas in other poritons, it will be behind. The dropping/duplicating of frames during capture seems like one of the best ways to avoid this. Additionally, it allows you to keep a standard framerate.
Dynamic audio resampling during capture sounds like it could work, but I don't know how feasible it is.
Mark:
Yup, VirtualDub will synchronize captures like AVI_IO. However, Avery Lee has said that AVI_IO's algorithm is better in that it doesn't have to drop/duplicate as many frames to maintain synch. I don't know for sure if this has changed in the past few revisions of VirtualDub, but I don't think it has.
-Cart
http://www.geocities.com/lukesvideo/index.html
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.