using the Datastead Encoder
Note
The MP4, MKV, AVI, ASF, MP3 and WMA recordings through the Microsoft and GPU codecs do not use the Datastead Encoder; see Recording methods and properties.
The Datastead Encoder gives access to the FFmpeg codecs of the Datastead Multipurpose Encoder, used to:
- compress video in various formats including MPEG4, MJPEG, H264 and HEVC, optionally with the GPU encoder if available (NVidia, AMD and Intel QuickSync supported),
- compress audio in various formats including AAC and MPEG2,
- record to file in various container formats (.avi, .mp4, .mkv, etc.),
- stream in various formats like UDP, RTMP, RTP, etc.
Compared to TVideoGrabber alone, the Datastead Encoder adds:
- the MOV format and the other FFmpeg formats,
- the reencoding and merging of clips,
- network streaming (UDP, RTMP, RTP, SRT, built-in RTSP server, etc.),
- the FFmpeg codecs (H.264, HEVC, MPEG-4, etc.),
- the settings through Encoder_SetInt / Encoder_SetStr,
- several encoder instances for the same TVideoGrabber component (Encoders_CreateInstanceForRecording, Encoders_CreateInstanceForStreaming).
FFmpeg codecs and formats
The Multipurpose Encoder includes an LGPL build of FFmpeg with the encoders and formats below (FFmpeg names in parentheses). The GPU encoders require the corresponding GPU and an up-to-date graphics driver.
Video:
- H.264: OpenH264 software encoder (libopenh264), NVidia NVENC (h264_nvenc), Intel QuickSync (h264_qsv), AMD AMF (h264_amf), Media Foundation (h264_mf), Direct3D 12 (h264_d3d12va)
- HEVC (H.265): Kvazaar software encoder (libkvazaar), NVidia NVENC (hevc_nvenc), Intel QuickSync (hevc_qsv), AMD AMF (hevc_amf), Media Foundation (hevc_mf), Direct3D 12 (hevc_d3d12va)
- AV1, GPU encoders only: NVidia NVENC (av1_nvenc), Intel QuickSync (av1_qsv), AMD AMF (av1_amf), Media Foundation (av1_mf), Direct3D 12 (av1_d3d12va)
- VP8 / VP9: libvpx (libvpx_vp8, libvpx_vp9), Intel QuickSync (vp9_qsv)
- MPEG-4 part 2 (mpeg4), MPEG-1 / MPEG-2 (mpeg1video, mpeg2video, mpeg2_qsv), MJPEG (mjpeg, mjpeg_qsv), Theora (libtheora), H.263 (h263, h263p), Flash video (flv, flashsv, flashsv2), WMV 7 / 8 (wmv1, wmv2), MS-MPEG4 v2 / v3 (msmpeg4v2, msmpeg4v3), DV (dvvideo)
- Intermediate and lossless codecs: ProRes (prores, prores_ks, prores_aw), DNxHD / DNxHR (dnxhd), CineForm (cfhd), FFV1 (ffv1), HuffYUV (huffyuv, ffvhuff), Ut Video (utvideo), MagicYUV (magicyuv), JPEG 2000 (jpeg2000), JPEG-LS (jpegls), QuickTime Animation (qtrle), v210, raw video (rawvideo)
- Images and animations: PNG, APNG, GIF, BMP, TIFF, etc.
Audio:
- AAC (aac, aac_mf), MP3 (libmp3lame, mp3_mf), Opus (libopus, opus), Vorbis (vorbis), AC-3 / E-AC-3 (ac3, eac3, ac3_mf), MP2 (mp2), FLAC (flac), ALAC (alac), WavPack (wavpack), TTA (tta), TrueHD / MLP (truehd, mlp), DTS (dca), Speex (libspeex), WMA v1 / v2 (wmav1, wmav2), G.722 / G.723.1 / G.726, PCM (all sample formats), ADPCM
Containers:
- MP4, MOV, 3GP / 3G2, ISMV, F4V, MKV / MKA, WebM, AVI, MPEG-TS, MPEG-PS (VOB, DVD, SVCD, VCD), FLV, ASF / WMV, MXF (OP1a, OP-Atom, D-10), Ogg (OGG, OGV, OGA, Opus, Speex), NUT, GXF, WTV, DV
- Elementary streams (H.264, HEVC, AV1 OBU, IVF, MJPEG, etc.), audio files (MP3, ADTS AAC, AC-3, E-AC-3, FLAC, WAV / W64, AIFF, CAF, MP2, etc.), image sequences
- HLS, DASH, segmented outputs
Network streaming:
- RTMP (rtmp, rtmps, rtmpt, rtmpe), RTSP (publishing to a server), RTP / SRTP, UDP (MPEG-TS), SRT (libsrt), HTTP / HTTPS / Icecast, HLS / DASH, WHIP (WebRTC), several outputs at once (tee), and the built-in RTSP server of the Multipurpose Encoder
In encoder mode, the codecs are selected by name, e.g. Encoder_SetStr (ID, Enc_Video_Codec, "hevc"), and the GPU encoder with Enc_Video_GPU_Encoder (see "Configuration of the encoder" below). In FFmpeg command-line mode, the FFmpeg encoder names above are used directly, e.g. -vcodec h264_nvenc; see Record/Stream/Merge/Transcode through the Datastead Multipurpose Encoder.
The Datastead Encoder requires version 2 or newer of the Datastead Multipurpose Encoder to be installed. However, it does not launch FFmpegLGPL.exe, and does not require running any external process.
One or more Datastead Encoder instances can be associated with a given TVideoGrabber component (e.g. one encoder instance performs the recording and another instance performs the streaming of the same TVideoGrabber instance).
A Datastead Encoder instance can record what is being displayed/rendered to a file, or send a live stream to the network.
Adding an encoder instance returns a unique ID, which is then used to configure this instance.
Installation
To install it, use one of the following options.
Option 1
Run the .exe installer located in the "Install" folder of the Multipurpose Encoder package. TVideoGrabber then locates the binaries automatically.
Option 2
Copy the x86 and x64 folders containing the encoder binaries either directly under the folder where the application's ".exe" is located, or to another folder specified with VideoGrabber.ExtraDLLPath.
Example of layout with the binaries under the application folder:
c:\appfolder\application.exe
c:\appfolder\x86
c:\appfolder\x64
Example with another folder:
VideoGrabber.ExtraDLLPath = "c:\AnotherFolder"
and the corresponding layout:
c:\appfolder\application.exe
c:\AnotherFolder\x86
c:\AnotherFolder\x64
Activation and configuration
Note
The instance and parameters must be configured before starting the video.
Recording
The recording is described in Recording through the Datastead Encoder.
Streaming
The streaming is described in Streaming through the Datastead Encoder.
Configuration of the encoder
The encoder is configured through the Encoder_SetInt and Encoder_SetStr functions.
ENCODER_RECORDING_ID (0) is the encoder used by the TVideoGrabber recording functions (StartRecording, RecordToNewFileNow, etc.). An instance created by Encoders_CreateInstanceForRecording or Encoders_CreateInstanceForStreaming is configured with the ID returned by these functions, and is used only once enabled with Encoder_SetInt (ID, Enc_IsActive_bool, 1).
The integer settings are listed in TEncoder_int, the string settings in TEncoder_str and the GPU encoders in TGPUEncoder.
Examples of values that can be passed:
To select the codec:
Encoder_SetStr (ENCODER_RECORDING_ID, Enc_Video_Codec, "mjpeg");
Encoder_SetStr (ENCODER_RECORDING_ID, Enc_Audio_Codec, "aac");
Encoder_SetStr (ENCODER_RECORDING_ID, Enc_Video_Codec, "mpeg4");
Encoder_SetStr (ENCODER_RECORDING_ID, Enc_Video_Codec, "mpeg2video");
Encoder_SetStr (ENCODER_RECORDING_ID, Enc_Video_Codec, "jpeg");
Encoder_SetStr (ENCODER_RECORDING_ID, Enc_Video_Codec, "h264");
Encoder_SetStr (ENCODER_RECORDING_ID, Enc_Video_Codec, "hevc");
To configure the GPU encoder (usually for the "h264", "hevc" or "mjpeg" codecs):
Encoder_SetInt (ENCODER_RECORDING_ID, Enc_Video_GPU_Encoder, (int) Enc_GPU_Intel_QSV);
Possible values include Enc_GPU_None, Enc_GPU_Auto, Enc_GPU_Intel_QSV, Enc_GPU_NVidia_NVENC and Enc_GPU_AMD_AMF.
To set the bit rate:
Encoder_SetInt (ENCODER_RECORDING_ID, Enc_Video_BitRate_kb, 2000);
To configure the bit rate control:
Encoder_SetInt (ENCODER_RECORDING_ID, Enc_Video_rc_BufferSize_kb, 1000);
Encoder_SetInt (ENCODER_RECORDING_ID, Enc_Video_rc_MinBitRate_kb, 2000);
Encoder_SetInt (ENCODER_RECORDING_ID, Enc_Video_rc_MaxBitRate_kb, 2000);
To set the encoded audio format (by default, the sample rate and channels of the audio source; the audio is converted when they differ):
Encoder_SetInt (ENCODER_RECORDING_ID, Enc_Audio_Output_SamplesPerSec, 48000);
Encoder_SetInt (ENCODER_RECORDING_ID, Enc_Audio_Output_Channels, 2);
Enc_Audio_SamplesPerSec and Enc_Audio_Channels describe the audio received by the encoder: they are set from the audio source when the video starts.