Skip to content

VideoCompressors

property, read-only

Delphi
property VideoCompressors: string read GetVideoCompressors;
C++Builder
__property System::UnicodeString VideoCompressors = {read=GetVideoCompressors};
C#
public string VideoCompressors { get; }
VB.NET
Public ReadOnly Property VideoCompressors As String
C++/Qt
wchar_t *GetVideoCompressors ();

Returns a string that contains the list of the video compressors available on the current platform.

This list can be assigned to list-based controls, e.g.:

ComboBox1.Items.Text := VideoGrabber1.VideoCompressors;

To retrieve the index of a video compressor programmatically, use the FindIndexInListByName function:

VideoGrabber.VideoCompressor := VideoGrabber.FindIndexInListByName (VideoGrabber.VideoCompressors, 'name of my video encoder', false, true);

The Media Foundation video encoders of the platform (Windows software encoders, NVIDIA / Intel / AMD GPU encoders), e.g. "H264 GPU (Nvidia)", "H264 CPU (Microsoft)", "H264 (Auto)" (best encoder of the codec, GPU first), are listed after the Datastead Multipurpose Encoder (index 0) and before the DirectShow compressors.

An encoder or a DirectShow compressor that appears after the first build of the list (e.g. RefreshDevicesAndCompressorsLists invoked after the installation of a driver or a codec) is appended at the end of the list. Select the compressors by name (FindIndexInListByName) rather than by a fixed index.

The Media Foundation encoders are used through the Datastead MFT Encoder of TVideoGrabber, without registration, with AVI and the other multiplexers, and with MP4 (RecordingMethod = rm_MP4: the H.264 compressed by the encoder is written as is). VideoCompression_KeyFrameRate / VideoCompression_Quality apply to them when set to values other than their defaults, or to any value >= 0 with SetVideoCompressionSettings; the Encoder_SetInt / Encoder_SetStr settings do not apply to them (FFmpeg codecs of the Datastead Multipurpose Encoder only).

The settings of a Media Foundation video encoder entry can be edited with ShowDialog (dlg_VideoCompressor): rate control (VBR, CBR, constant quality), bit rate, peak bit rate, quality, key frame interval, profile, low latency mode, CPU encoder when the GPU encoder cannot be used. They are saved for that entry, like the settings of the DirectShow compressors (registry; SaveCompressorSettingsToDataString / LoadCompressorSettingsFromDataString), and used from the next recording. VideoCompression_KeyFrameRate / VideoCompression_Quality / VideoCompression_DataRate take precedence when set to values other than their defaults, and so do KeyFrameRate 15 / Quality 1.0 set with SetVideoCompressionSettings (applied when recording).

The "MJPEG CPU (Microsoft)" entry encodes each frame as a JPEG image with the JPEG encoder of Windows (Windows Imaging Component), several frames at once on multi-core CPUs; every frame is a key frame (e.g. AVI recording, RecordingMethod = rm_AVI). Its quality is set with VideoCompression_Quality (0.01 to 0.99; 1.0, the default value of the property, is not applied, except with SetVideoCompressionSettings) or with ShowDialog (dlg_VideoCompressor), 85 by default. Windows provides no MJPEG encoder for the GPU: a "MJPEG GPU (vendor)" entry appears only if a GPU driver installs one. With RecordingMethod = rm_MP4 this entry is not used: the video is encoded in H.264 (with a warning).

The "Datastead Multipurpose Encoder" entry (index 0) is always listed. When the Datastead Multipurpose Encoder is installed, this entry wraps the FFmpeg codecs (H.264, HEVC, AV1, VP9, MPEG-4, ProRes...), configured by Encoder_SetInt / Encoder_SetStr or ShowDialog (dlg_VideoCompressor), see using the Datastead Encoder. When it is not installed, a recording that selects it (CompressionMode = cm_CompressOnTheFly, CompressionType = ct_Video or ct_AudioVideo; not ASF, WebM, MPEG or MOV) uses the natively supported "H264 (Auto)" entry instead, with the warning "Datastead Multipurpose Encoder selected as video compressor but not installed, using instead H264 (Auto)" (OnLog).

To avoid this warning, choose one of the other video compressors listed, e.g.:

VideoGrabber.VideoCompressor = VideoGrabber.VideoCompressorIndex ("H264 GPU (Nvidia)");

Note: when the application starts, the VideoCompressors and AudioCompressors lists are populated with the codecs currently installed. To refresh the compressor lists after installing/uninstalling codecs without exiting/restarting the application, invoke RefreshDevicesAndCompressorsLists.