Table of Contents

Class CommonMFSettings

Namespace
VisioForge.Core.Types.FFMPEGEXE
Assembly
VisioForge.Core.dll

Common Media Foundation encoders settings.

public class CommonMFSettings : BasicVideoSettings

Inheritance

Derived

Inherited Members

Examples

var mfSettings = new CommonMFSettings
{
    Encoder = VideoEncoder.H264_MF,
    Bitrate = 5000,
    RateControl = H264MFRateControl.VBR,
    Scenario = H264MFScenario.DisplayRemoting,
    ForceHWEncoding = true
};
// This configures FFMPEG to use: -c:v h264_mf -b:v 5000k -rc vbr ...

Remarks

This class configures video encoding parameters for Microsoft Media Foundation (MF) encoders when used through FFMPEG. Media Foundation is Microsoft's multimedia framework that provides hardware-accelerated video encoding on Windows platforms. When FFMPEG is compiled with Media Foundation support, it can leverage GPU-based encoding through various vendor implementations including Intel Quick Sync Video, AMD VCE, and NVIDIA NVENC.

Media Foundation encoders in FFMPEG are accessed using codec names like:

  • h264_mf: H.264/AVC encoding via Media Foundation
  • hevc_mf: H.265/HEVC encoding via Media Foundation

These settings control the behavior of the underlying hardware encoder, providing options for rate control, usage scenarios, and hardware acceleration enforcement.

Properties

ForceHWEncoding

Gets or sets a value indicating whether hardware encoding must be used exclusively.

public bool ForceHWEncoding { get; set; }

Property Value

bool

Remarks

When set to true, FFMPEG will fail if hardware encoding is not available rather than falling back to software encoding. This ensures predictable performance and prevents unexpected CPU usage spikes.

Hardware encoding requirements:

  • Compatible GPU (Intel HD Graphics, NVIDIA GeForce, AMD Radeon)
  • Updated graphics drivers with Media Foundation support
  • Windows 7 or later (Windows 10 recommended for full feature support)

In FFMPEG, this affects encoder initialization:

  • True: Forces hardware-only mode, fails if unavailable
  • False: Attempts hardware first, falls back to software if needed

Common failure scenarios when ForceHWEncoding is true:

  • Running in a virtual machine without GPU passthrough
  • Outdated or missing graphics drivers
  • GPU already at maximum encoding session limit
  • Unsupported resolution or profile for hardware encoder

RateControl

Gets or sets rate control mode for the Media Foundation encoder.

public H264MFRateControl RateControl { get; set; }

Property Value

H264MFRateControl

Remarks

Rate control determines how the encoder manages bitrate allocation across frames. This directly maps to FFMPEG's rate control options for Media Foundation codecs:

  • CBR (Constant Bitrate): Maintains a fixed bitrate, ideal for streaming
  • VBR (Variable Bitrate): Adjusts bitrate based on content complexity for better quality
  • Quality: Constant quality mode, prioritizes quality over file size

In FFMPEG command line, this translates to options like:

  • CBR: -rc cbr -b:v [bitrate]
  • VBR: -rc vbr -b:v [bitrate] -maxrate [max] -minrate [min]
  • Quality: -rc quality -q:v [quality_level]

Scenario

Gets or sets the usage scenario for optimized encoding parameters.

public H264MFScenario Scenario { get; set; }

Property Value

H264MFScenario

Remarks

The scenario setting configures the Media Foundation encoder with predefined optimization profiles for specific use cases. This affects internal encoder decisions about frame structure, buffering, and quality trade-offs.

Common scenarios and their optimizations:

  • Default: Balanced settings for general video encoding
  • DisplayRemoting: Low latency for screen sharing/remote desktop (reduced B-frames)
  • VideoRecording: Optimized for local recording with higher quality
  • Archive: Maximum quality for long-term storage
  • VideoConferencing: Ultra-low latency with adaptive quality
  • LiveStreaming: Balance between latency and buffering for streaming

In FFMPEG, this maps to the -scenario option for MF encoders: ffmpeg -i input.mp4 -c:v h264_mf -scenario displayremoting output.mp4

Each scenario may adjust GOP size, reference frames, and rate control behavior to match the specific requirements of the use case.