Skip to content

FFMPEG Encoder Output (FFMPEGOutput)

Video Capture SDK .NET Video Edit SDK .NET

VideoCaptureCore VideoEditCore

FFMPEGOutput writes the file through the VisioForge FFMPEG Encoder, a DirectShow filter built on the SDK's own LGPL FFmpeg build. The encoder runs inside the capture or edit graph, in your process, on x86 and x64. To run ffmpeg.exe with your own command line instead, use FFMPEG.exe output.

Edition

FFMPEGOutput requires the Premium edition in VideoCaptureCore and the Professional edition in VideoEditCore.

Containers and codecs

Set the container with OutputFormat (FFMPEGOutputFormat) and the codecs with Video_Codec (FFMPEGVideoCodec) and Audio_Codec (FFMPEGAudioCodec). Choose codecs the container accepts, for example:

Container OutputFormat Video Audio
WebM WebM VP8, VP9 Vorbis, OPUS
Ogg OGG none Vorbis
Matroska MKV MPEG4, VP9 and others FLAC, Vorbis, OPUS, AAC
MP4 MP4 MPEG4 (the default) and others AAC (the default), MP3

Record video and audio

using VisioForge.Core.Types.Output;

videoCapture.Output_Format = new FFMPEGOutput
{
    OutputFormat = FFMPEGOutputFormat.WebM,
    Video_Codec = FFMPEGVideoCodec.VP8,
    Audio_Codec = FFMPEGAudioCodec.Vorbis,
    Video_Bitrate = 2000000, // bits per second
    Audio_Bitrate = 128000
};
videoCapture.Output_Filename = "output.webm";

VideoEditCore takes the same object in Output_Format in VideoEditMode.Convert.

Audio-only files

Both engines write an audio-only file through FFMPEGOutput:

  • VideoCaptureCore: set Mode = VideoCaptureMode.AudioCapture.
  • VideoEditCore: add only audio files to the timeline.
videoCapture.Mode = VideoCaptureMode.AudioCapture;
videoCapture.Audio_RecordAudio = true;
videoCapture.Output_Format = new FFMPEGOutput
{
    OutputFormat = FFMPEGOutputFormat.OGG,
    Audio_Codec = FFMPEGAudioCodec.Vorbis
};
videoCapture.Output_Filename = "voice.ogg";
await videoCapture.StartAsync();
videoEdit.Mode = VideoEditMode.Convert;
await videoEdit.Input_AddAudioFileAsync(new AudioSource("input.wav"));
videoEdit.Output_Format = new FFMPEGOutput
{
    OutputFormat = FFMPEGOutputFormat.MKV,
    Audio_Codec = FFMPEGAudioCodec.FLAC
};
videoEdit.Output_Filename = "output.mka";
await videoEdit.StartAsync();

Settings the encoder applies

The FFMPEG Encoder applies these FFMPEGOutput settings:

  • OutputFormat, Video_Codec, Audio_Codec;
  • Video_Bitrate in bits per second (0 gives 3 Mbps);
  • Audio_Bitrate in bits per second;
  • Audio_SampleRate: the nearest rate the audio codec supports.

VideoCaptureCore and VideoEditCore do not apply the settings below. The file keeps the source's value or the encoder's own default:

  • Video_Width, Video_Height: the video keeps the source's frame size;
  • Video_AspectRatio_W, Video_AspectRatio_H;
  • Video_Interlace, Video_TVSystem;
  • Video_BufferSize, Video_MinBitrate, Video_MaxBitrate;
  • Video_Profile, Video_Level;
  • Audio_Channels: the audio keeps the source's channel count.

Deployment

Add the FFMPEG redist package of your platform: VisioForge.DotNet.Core.Redist.FFMPEG.x64 or VisioForge.DotNet.Core.Redist.FFMPEG.x86. It carries VisioForge_FFMPEG_Encoder_x64.ax (x64) or VisioForge_FFMPEG_Encoder.ax (x86) and the FFmpeg DLLs the encoder uses.