Encoder mode: encoding without a command line
In encoder mode the encoding is described by settings: a video codec, a resolution, a bit rate, a GPU encoder, an audio codec, and so on. The FFmpeg command line is built internally, so the FFmpeg syntax never has to be written nor maintained by the application.
This is the recommended mode
The FFmpeg command-line mode is only needed when an FFmpeg option that the encoder settings do not expose is required: video filters, several outputs at once, unusual muxers, and so on.
The same settings are used from the TVideoGrabber SDK and from DirectShow; only the way they are edited differs.
From the TVideoGrabber SDK
When the package is installed, the TVideoGrabber SDK detects it automatically and offers it as the "Datastead Encoder" codec for recording, streaming, transcoding and merging. The settings are then ordinary SDK properties, set programmatically.
See Using from TVideoGrabber (encoder mode).
From a DirectShow application
A third filter is registered for this mode: Datastead Encoder, CLSID_DatasteadDirectShowEncoder = {6E990010-F426-491B-8CBE-2CA95A70B6D5}.
It has the same Video Input and Audio Input pins as the Datastead Multipurpose Encoder, but it is configured through its encoder settings instead of a command line.
| Interface | Purpose |
|---|---|
ISpecifyPropertyPages |
Returns a single property page, the encoder settings page, which edits every setting listed below. The command-line filters return two pages instead (command line and log). |
IPersistStream |
Saves and restores the whole set of settings, so that a configuration edited once can be stored by the application and applied again later. |
IDatasteadMultipurposeDirectShowEncoder and the other interfaces |
Available as on the other filters, for the version, the log, the progress information and the pin information. |
Displaying the settings page is the standard DirectShow sequence:
ISpecifyPropertyPages *pSpec = NULL;
if (SUCCEEDED (DatasteadEncoder->QueryInterface (IID_ISpecifyPropertyPages, (void**) &pSpec))) {
CAUUID pages;
if (SUCCEEDED (pSpec->GetPages (&pages))) {
IUnknown *pFilterUnk = NULL;
DatasteadEncoder->QueryInterface (IID_IUnknown, (void**) &pFilterUnk);
OleCreatePropertyFrame (hwndOwner, 0, 0, L"Datastead Encoder", 1, &pFilterUnk,
pages.cElems, pages.pElems, 0, 0, NULL);
pFilterUnk->Release();
CoTaskMemFree (pages.pElems);
}
pSpec->Release();
}
The settings can then be saved with IPersistStream::Save and restored with IPersistStream::Load, exactly as a graph editor persists a filter in a .grf file.
The encoder settings
The settings edited by the encoder settings page, and carried by IPersistStream:
Video
| Setting | Description |
|---|---|
| Video codec | Name of the video encoder, for example h264 or hevc |
| Width, height | Encoded resolution; left at 0, the resolution of the connected video pin is used |
| Bit rate (kbit/s) | Target video bit rate |
| Min bit rate, max bit rate, buffer size (kbit/s) | Rate-control settings of the encoder |
| Quality, min and max | Lowest and highest quantizer allowed (qmin / qmax), 1 to 51: the lower the value, the better the quality and the larger the file; left at 0, the default of the encoder |
| IDR interval | Distance between two key frames, in frames |
| Max B-frames | Maximum number of consecutive B-frames |
| Thread count | Number of threads of the video encoder; left at 0, 4 threads |
| GPU encoder | None, Auto, Intel QSV, NVidia NVENC or AMD AMF; Auto selects the hardware encoder available on the machine, and falls back to software encoding when there is none |
| Extra parameters | Additional FFmpeg options, for the cases that the settings above do not cover: -name value pairs, for example -g:v 60 -bf:v 0; the :v / :a suffix applies an option to the video / audio encoder only |
Audio
| Setting | Description |
|---|---|
| Audio codec | Name of the audio encoder, for example aac |
| Bit rate (kbit/s) | Target audio bit rate |
| Sample rate | Encoded sample rate: 0 (sample rate of the source), 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000 or 96000 Hz. The audio is resampled when it differs from the source; a rate that the audio codec does not support is replaced by the closest supported one |
| Bits per sample | Not used, shown disabled: the encoded sample format is the one of the audio codec |
| Channels | Encoded number of channels: 0 (channels of the source), 1 (mono) or 2 (stereo) |
Reset to default
The settings page also has a Reset to default button, which reloads the default settings of the encoder.
The destination of the encoding, a file path or a streaming URL, is part of the encoder configuration as well; from TVideoGrabber it is the recording or streaming destination set through the SDK.
Quick check from GraphEdit
Insert the Datastead Encoder filter, connect a video source and, if needed, an audio source, then right-click the filter to open its encoder settings page. No command line is involved. See Quick start from GraphEdit.