Skip to content

Dropped frames and audio/video sync problems

Dropped frames

The live video and audio sources stream data at a fixed frame rate: the processor must have finished processing the previous frame when the next frame arrives, otherwise the frame is dropped and replaced by a blank frame.

The dropped frame count can be retrieved by reading the DroppedFrames property. Because reading the dropped frames requires a variable amount of CPU (depending on the video capture device), the polling of the dropped frames count is controlled by the DroppedFramesPollingInterval property (specified in seconds):

  • DroppedFramesPollingInterval = -1 (default) reads the dropped frames count each time a new frame is received,
  • DroppedFramesPollingInterval = 20 polls the dropped frames count every 20 seconds,
  • DroppedFramesPollingInterval = 0 disables the polling of dropped frames (recommended to save CPU).

Disk access

During recording, one major problem is the block allocation when the operating system extends the recording file. When allocating new blocks, the operating system places significant demands on the CPU/disk resources, and this can cause dropped frames.

This problem occurs mainly when capturing uncompressed video in AVI format. It is less significant when using a video compressor on the fly (or when recording in ASF format), because the file size is 10 or more times smaller.

The best solution to avoid this problem is to record to an SSD. If a lot of disk space is needed for multiple recordings, move each video clip from the SSD to a normal HDD once it is recorded, so that the SSD is used only as a temporary disk for the recording.

FAT32 is not efficient for large capture files: it generates large numbers of dropped frames when new disk blocks are allocated. Always choose NTFS partitions, on disks with fast access time and cache memory.

Frame grabber

The frame grabber adds an additional step in the stream processing, and therefore requires more CPU. When there is no need to capture frames or perform text or graphic overlays during recording, disable it by setting FrameGrabber = fg_Disabled before invoking StartRecording.

Audio rendering

During the recording of video + audio streams, disable AudioDeviceRendering if possible (it renders the sound through the loudspeakers). This lets TVideoGrabber capture the video and audio streams without having to split the audio stream. Audio rendering must be disabled before invoking StartRecording.

Video display

To save CPU, the video window can be disabled during the recording: set VideoRenderer = vr_None before invoking StartRecording.

Video size and frame rate

The larger the video size and the higher the frame rate, the higher the CPU and disk consumption. Reducing the video size to 320x240 and reducing the frame rate help fix audio sync problems.