Modified VirtualDub* Capture Routine with
High Quality Realtime Sample Rate Conversion
and Phase Servo Loop


When capturing video with your TV-card and audio with your soundcard simultaneously, after some time audio becomes desyncronized with video. This is because the clock of the soundcard is not syncronized or locked to the framerate of the incoming TV-Signal. Thus the number of audio-samples per frame will change slowly in time. When adding some timestamps while recording, or using data framing techniques and e.g. bit stuffing mechanisms, this is no problem anymore, when using these information for playback.
For short sequence capturing, that does not matter because this effect becomes visible only when recording some longer periods (depends on the quality of the soundcard-oscillator and on the oscillator(s) in the tv-broadcast-station or in your VCR).
In order to syncronize audio and video, many capture programs throw away or duplicate frames when audio is behind or in front of video.


In order to syncronize audio and video we apply a realtime sample rate conversion to the audio signal and do not throw frames away, anymore. That is, we have some means to permanently measure the time delay between audio and video during the capturing process and e.g. if there are too much audio samples per frame we reduce the number of audio samples in such a way, that there is no audible degradation (in the professional music domain, sample rate conversion is applied when mixing digital audio of different sources, but in a hardware-circuit like the AD1896 from Analog Devices). In order to avoid additional jitter, the measured time delay is feed into a servo loop with a high time constant.
So even when capturing many hours, the number of samples is as specified (e.g. PAL with 25frames per second and 44.1kHz audio sampling frequency, there have to be exactly 44100/25 = 1764 samples per frame).


  • high quality sample rate conversion for near lossless audio-video-syncronisation without frame drops
  • 32-tap linear phase FIR filter with 256 subfilter and linear interpolation of filter coefficients
  • continous stream sample rate conversion
  • reliable phase offset estimation
  • stable designed phase servo loop (PI / VZ1 controll circuits)
  • lost of signal detection
  • smooth servo loop operation, well designed time constants
  • display of frequency shifts between TV-signal-, audio-clock and other sync-information
  • speed optimized code

Short Description:

In order to activate the realtime sample rate conversion, switch on the upper radio button "Capture->Timing->resample audio data ...". When activating button two, the program-behaviour should be as normal, i.e. dropping/adding frames if it is necessary for a proper AV-sync. In the third mode, no syncing is applied but a frame-drop detection is active (as in all modes) and doubles the last frame, if there is really a lost frame. When active, on the status-line there are displayed sync-informations and the algorithms are applied. Because the audio signal is processed, only uncompressed PCM audio format is supported for the sample rate conversion and up to now only 16bit mono and stereo. The first seconds when capturing, there is a measurement phase to find a sync point. For better operation set the audio block size to a smaller value e.g. 18000 bytes for 16bit mono and 36000 bytes @ 16bit stereo (Capture->Settings->Audio buffer size).
Statusline information (latest release):
- sync modus: 1/2/3, applied sync algorithm corresponding to the methods in the timing dialog
- delta_AV (all): instantaneous (integral) freqency offset between audio before resampling and video
- phase: weigthted averaged instantaneous phase offset between video and resampled audio
- adjust: number of audiosamples which are added (with means of high quality SRC) per audio block

Installation (instructions for latest release only):

  • copy the executable "VirtualDub_Sync.exe" in your existing VirtualDub directory.
  • in VirtualDub capture modus go to menu "Capture->Timing" and select the sync modus.
    When using mode 1 together with a compressed audio-format, mode 2 is applied (see statusline).
  • (optional but recommended) go to menu "Capture->Settings" and set the audiobuffer-size to
    36000 (for 16bit stereo PCM) or 18000 (for 16bit mono PCM)


Source code (modifications only):
Latest release:
Old versions:



2003/09/25: Released VirtualDub-1_5_04_sync1_04
- added sync-routines and modified bt848-tweaker in VirtualDub 1.5.04
- added keyboard support for bt848-tweaker
- minor changes of bt848-tweaker layout and PAR-calculation
Released VirtualDub-1_4_13_sync1_04
- added keyboard support for bt848-tweaker
- minor changes of bt848-tweaker layout and PAR-calculation

2002/12/19: Released VirtualDub-1_4_13_sync1_03
- added sync-routines and modified bt848-tweaker in VirtualDub 1.4.13

2002/11/06: Released VirtualDub-1_4_11_sync1_03
- modified bt848-tweaker for proper CCIR-REC.601 compatible scaling
- minor changes of control loop constants
- changed NTSC-framerate sync constant from 29.97 to 30000/1001. This corresponds to a AV-delay
   of about 4 ms in older versions for one hour recording which is less than one frame (unnoticeable)
- bug: false dropping behaviour when "negative" dropped frames occur (should normally never happen) - fixed in 1_03
- added sync-routines and modified bt848-tweaker in VirtualDub 1.4.11

2002/05/08: Released VirtualDub-1_4_10_sync1_02
- little changes in status line display
- added new timing dialog with three sync modes
- drop/add frames if sample-rate-changing is not enough to ensure AV-syncronisation
- buffersize check for correct longword allignment
- bug: uncorrect memory deallocation when sync mode is disabled - fixed in 1_02
- added sync-routines in VirtualDub 1.4.10

2002/03/08: Released VirtualDub-1_4_9_sync1_01c (still beta)
- bug: overstearing audio produces spikes in the src-filter - fixed in 1_01c
- increased time constant of PI-controller in videoroutine: more stable behaviour
- added sync-routines in VirtualDub 1.4.9

2002/02/28: Released VirtualDub-1_4_8_sync1_01b




*) Based on VirtualDub from Avery Lee, see

For more details, bug reports, suggestions: (Andreas Dittrich)



VirtualDub Filter

Cedocida DV Codec