Dropped frames and audio/video sync problems

Prev

Next

 






































































































Dropped frames and audio/video sync problems

Description

DROPPED FRAMES

The live video and audio sources stream data at a fixed frame rate, and this means that 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 needs more or less CPU (depending of the video capture device), the number of dropped frames is not updated for every frame, but refreshed periodically according to the DroppedFramesPollingInterval property (specified in seconds).
E.g:
DroppedFramesPollingInterval = 20 polls the dropped frames count every 20 seconds.
DroppedFramesPollingInterval = 0 disables the polling of dropped frames (recommended to save CPU).

Disk access and preallocated files

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 times or more smaller.

The best solution to avoid this problem is to record to a SSD (if a lot of disk space is needed for multiple recording, once recorded move the video clip from the SSD to a normal HDD, so the SSD is used only as temporary disk just for the recording.

Another solution is to use an huge preallocated capture file, larger than the amount of data to capture. See the "preallocated capture file" section in the AVI recording chapter.
FAT 32 is not efficient for large capture files, generating large amounts of dropped frames when new disk blocs are allocated.
On Windows 2000 and Windows XP platforms, 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.
If you don't need to capture frames or perform text or graphics overlays during recording, simply disable it by setting FrameGrabber = fg_Disabled before invoking StartRecording.

Audio rendering
During recording of video + audio streams, disable if possible AudioDeviceRendering, that renders sound in the loudspeakers. This will let TVideoGrabber capture the video and audio streams without having to split the audio stream. Audio rendering must be disabled before invoking StartRecording.

Video Display
In order to save CPU you can disable the video window during the recording. Simply set VideoRenderer = vr_None before invoking StartRecording.

Video size and frame rate
Of course, larger is the video size and higher is the frame rate, higher is the CPU and disk consumption. Reducing the video size to 320x240 and the frame rate will help to fixing audio sync problems.