Class H264AMFSettings
- Namespace
- VisioForge.Core.Types.FFMPEGEXE
- Assembly
- VisioForge.Core.dll
H264 AMF encoder settings for AMD GPU hardware-accelerated encoding via FFMPEG.
public class H264AMFSettings : BasicVideoSettingsInheritance
Inherited Members
Remarks
This class configures AMD's Advanced Media Framework (AMF) H.264 encoder, which utilizes the Video Coding Engine (VCE) hardware block in AMD GPUs for accelerated video encoding.
Hardware requirements:
- AMD GPU: Radeon RX 400 series or newer (VCE 3.0+)
- Older GPUs: Radeon HD 7700+ support basic encoding (VCE 1.0+)
- APUs: Most AMD APUs include VCE support
- Drivers: Latest AMD drivers with AMF support
VCE versions and capabilities:
- VCE 1.0: Basic H.264 encoding (GCN 1st gen)
- VCE 2.0: Improved quality and performance (GCN 2nd gen)
- VCE 3.0: High Efficiency Video Coding, improved H.264 (GCN 3rd gen)
- VCE 4.0+: Further quality improvements, better B-frame support
FFMPEG integration: The h264_amf encoder in FFMPEG provides direct access to AMD's hardware encoder. Basic usage: ffmpeg -i input.mp4 -c:v h264_amf -b:v 5M output.mp4
Performance characteristics:
- Encoding speed: 2-10x faster than software encoding
- Power efficiency: 50-70% less power than CPU encoding
- Quality: Generally good, slightly below x264 medium preset
- Latency: Can achieve sub-frame latency in specific modes
Best practices:
- Use High Profile for best compression
- Enable B-frames for better quality (if latency permits)
- Set appropriate bitrate for your use case
- Monitor GPU usage to avoid bottlenecks
- Consider multiple streams for GPU load balancing
Constructors
H264AMFSettings()
Initializes a new instance of the VisioForge.Core.Types.FFMPEGEXE.H264AMFSettings class with AMD AMF defaults.
public H264AMFSettings()Remarks
Default settings are optimized for general transcoding with good compatibility. The encoder is set to use AMD's h264_amf hardware encoder in FFMPEG.
Properties
AUD
Insert Access Unit Delimiter NAL units for better stream parsing.
public bool AUD { get; set; }Property Value
Remarks
AUD NAL units mark the beginning of each access unit (frame) in the bitstream. This aids in stream synchronization and parsing.
Required for:
- Some broadcast standards
- Certain streaming protocols
- Better error recovery
- Transport stream muxing
Adds minimal overhead (few bytes per frame).
FFMPEG: -aud 1 Default: false
BFDeltaQP
Quality offset for B-frames relative to P-frames.
public int BFDeltaQP { get; set; }Property Value
Remarks
Adjusts B-frame quantization relative to P-frames:
- Range: -10 to 10
- Positive: Lower quality (higher QP) for B-frames
- Negative: Higher quality (lower QP) for B-frames
- 0: Same quality as P-frames
Default of 4 means B-frames use QP = P-frame QP + 4. This is optimal since B-frames aren't reference frames.
FFMPEG: -bf_delta_qp [value] Default: 4
BFRef
Allow B-frames to be used as reference frames for better compression.
public bool BFRef { get; set; }Property Value
Remarks
When enabled, B-frames can be referenced by other frames, creating a B-frame pyramid structure. This improves compression efficiency but increases complexity and latency.
Benefits:
- 5-10% better compression
- Better temporal prediction
- Smoother motion handling
Drawbacks:
- Increased decoder complexity
- Higher latency (more frames buffered)
- Not compatible with all devices
FFMPEG: -bf_ref 1 Default: true (disable for low-latency)
BFRefDeltaQP
Quality offset for reference B-frames in B-pyramid.
public int BFRefDeltaQP { get; set; }Property Value
Remarks
When B-frames are used as references (BFRef=true), this adjusts their quality relative to non-reference B-frames:
- Range: -10 to 10
- Lower values: Better quality for reference B-frames
- Higher values: Lower quality (saves bits)
Reference B-frames affect other frames' quality, so they typically need better quality than non-reference B-frames.
FFMPEG: -bf_ref_delta_qp [value] Default: 4
Coder
Entropy coding method (CABAC or CAVLC) for final compression.
public H264AMFCodingType Coder { get; set; }Property Value
Remarks
Entropy coding is the final lossless compression stage. Auto selection ensures profile compliance.
FFMPEG: -coder [auto|cabac|cavlc]
EnforceHRD
Enforce HRD (Hypothetical Reference Decoder) compliance for broadcast standards.
public bool EnforceHRD { get; set; }Property Value
Remarks
HRD ensures the bitstream can be decoded by standard-compliant decoders without buffer underflow or overflow. Required for broadcast and some streaming protocols. Slightly reduces compression efficiency.
FFMPEG: -enforce_hrd 1 Default: false
FillerData
Enable filler data NAL units to maintain exact constant bitrate.
public bool FillerData { get; set; }Property Value
Remarks
Filler data pads the bitstream when the encoder produces less data than the target bitrate. Essential for strict CBR requirements in broadcast. Wastes bandwidth but ensures consistent stream rate.
FFMPEG: -filler_data 1 Default: false
FrameSkipping
Enable frame skipping to maintain target bitrate under extreme conditions.
public bool FrameSkipping { get; set; }Property Value
Remarks
When enabled, the encoder may skip frames if it cannot maintain the target bitrate otherwise. Useful for real-time streaming with limited bandwidth. Skipped frames are replaced with frame copy commands.
Use cases:
- Low-bandwidth video calls
- Unstable network conditions
- Strict bitrate requirements
FFMPEG: -skip_frame 1 Default: false (may cause stuttering)
HeaderSpacing
Interval for SPS/PPS header insertion in frames.
public int HeaderSpacing { get; set; }Property Value
Remarks
Controls how often Sequence Parameter Set (SPS) and Picture Parameter Set (PPS) headers are inserted into the bitstream for random access and error recovery.
- Range: -1 to 1000
- -1: Default behavior (typically at each IDR)
- 0: Only at the beginning
- N: Every N frames
Use cases:
- Streaming: Set to GOP size for seek points
- Broadcast: Lower values for channel switching
- Recording: Higher values to save bits
FFMPEG: -header_spacing [value] Default: -1 (at each IDR frame)
IntraRefreshMB
Number of macroblocks to refresh per frame for gradual I-frame refresh.
public int IntraRefreshMB { get; set; }Property Value
Remarks
Intra refresh spreads I-frame data across multiple frames instead of having full I-frames. This reduces bitrate spikes and latency.
- Range: 0 to INT_MAX
- 0: Disabled (use regular I-frames)
- N: Refresh N macroblocks per frame
Example for 1920x1080:
- Total MBs: (1920/16) * (1080/16) = 8100
- For 1-second refresh at 30fps: 8100/30 = 270 MBs/frame
Benefits:
- No bitrate spikes from I-frames
- Lower latency
- Better for CBR streaming
FFMPEG: -intra_refresh_mb [value] Default: 0 (disabled)
Level
H.264 level that constrains resolution, frame rate, and bitrate.
public H264AMFLevel Level { get; set; }Property Value
Remarks
The level ensures decoder compatibility by limiting encoding parameters. Auto selection chooses the minimum level that supports your settings.
FFMPEG: -level [auto|1.0|2.0|3.0|4.0|4.1|5.0|5.1|...]
MEHalfPel
Enable half-pixel precision motion estimation for better quality.
public bool MEHalfPel { get; set; }Property Value
Remarks
Half-pixel motion estimation improves motion vector accuracy by searching at sub-pixel positions. This significantly improves quality with minimal performance impact on VCE hardware.
Benefits:
- Better motion prediction
- Reduced artifacts in motion
- 5-10% bitrate savings
Always enabled in modern VCE hardware.
FFMPEG: -me_half_pel 1 Default: true
MEQuarterPel
Enable quarter-pixel precision motion estimation for maximum quality.
public bool MEQuarterPel { get; set; }Property Value
Remarks
Quarter-pixel motion estimation further refines motion vectors to 0.25 pixel accuracy. This provides the best motion compensation quality at a slight performance cost.
Benefits:
- Highest motion accuracy
- Best quality for sports/action
- Additional 3-5% bitrate savings
May impact performance on older VCE versions.
FFMPEG: -me_quarter_pel 1 Default: true
MaxAUSize
Maximum Access Unit size for rate control (in bits).
public int MaxAUSize { get; set; }Property Value
Remarks
Limits the maximum size of an Access Unit (typically one frame) to prevent bitrate spikes. Useful for streaming with limited buffer capacity.
- Range: 0 to INT_MAX
- 0: No limit (default)
- Typical: Set to 2-3x average frame size
Example for 5 Mbps stream at 30fps:
- Average frame: 5,000,000 / 30 = 166,666 bits
- MaxAUSize: 500,000 bits (3x average)
FFMPEG: -max_au_size [value] Default: 0 (no limit)
PreAnalysis
Enable pre-analysis pass for improved encoding decisions.
public bool PreAnalysis { get; set; }Property Value
Remarks
Pre-analysis performs a fast initial pass to gather statistics about the video content before actual encoding. This enables better:
- Scene change detection
- Complexity analysis
- Bit allocation decisions
- Motion estimation initialization
Trade-offs:
- Increases latency by 1-2 frames
- Improves quality by 5-10%
- Slightly reduces encoding speed
- Better rate control accuracy
FFMPEG: -preanalysis 1 Default: false (enable for better quality)
Profile
H.264 profile that defines feature set and compatibility.
public H264AMFProfile Profile { get; set; }Property Value
Remarks
Profile selection is crucial for device compatibility and compression efficiency. Higher profiles offer better compression but may limit playback compatibility.
FFMPEG: -profile:v [main|high|constrained_baseline|constrained_high]
QPB
Quantization Parameter for B-frames (bidirectional frames) when using CQP mode.
public int QPB { get; set; }Property Value
Remarks
Controls quality of B-frames (bidirectionally-predicted frames):
- Range: -1 to 51
- -1: Use default/automatic
- Typically 3-5 points higher than P-frame QP
- Less critical as B-frames are not reference frames
B-frames improve compression efficiency but add latency. Not available in Baseline Profile or ultra-low latency modes.
FFMPEG: -qp_b [value] Default: -1 (automatic based on rate control)
QPI
Quantization Parameter for I-frames (keyframes) when using CQP mode.
public int QPI { get; set; }Property Value
Remarks
Controls quality of I-frames (intra-coded frames/keyframes):
- Range: -1 to 51
- -1: Use default/automatic
- 0: Highest quality (near lossless)
- 18-23: High quality range
- 23-28: Standard quality
- 28-35: Acceptable quality
- 35-51: Low quality
I-frames are reference frames, so their quality affects all dependent frames. Typically set 2-3 points lower (better quality) than P-frames.
FFMPEG: -qp_i [value] Default: -1 (automatic based on rate control)
QPP
Quantization Parameter for P-frames (predicted frames) when using CQP mode.
public int QPP { get; set; }Property Value
Remarks
Controls quality of P-frames (forward-predicted frames):
- Range: -1 to 51
- -1: Use default/automatic
- Typically 2-3 points higher than I-frame QP
- Main quality control for most content
P-frames make up the majority of frames in typical content. Their quality has the most impact on overall visual quality.
FFMPEG: -qp_p [value] Default: -1 (automatic based on rate control)
QualityMode
Quality preset that balances encoding speed versus output quality.
public H264AMFQuality QualityMode { get; set; }Property Value
Remarks
Affects motion estimation, mode decisions, and rate control complexity. Speed mode is default for real-time applications.
FFMPEG: -quality [speed|balanced|quality]
RateControl
Rate control method that determines bitrate allocation strategy.
public H264AMFRateControlMethod RateControl { get; set; }Property Value
Remarks
Critical setting that affects quality consistency and bitrate behavior. CBR is default for streaming compatibility.
FFMPEG: -rc [cqp|cbr|vbr_peak|vbr_latency]
Usage
Encoder usage preset that optimizes for specific use cases.
public AMFEncoderUsage Usage { get; set; }Property Value
Remarks
The usage preset configures internal encoder parameters for different scenarios. This affects latency, quality, and performance characteristics.
FFMPEG: -usage [transcoding|ultralowlatency|lowlatency|webcam]
VBAQ
Enable VBAQ (Variance Based Adaptive Quantization) for better visual quality.
public bool VBAQ { get; set; }Property Value
Remarks
VBAQ improves perceptual quality by allocating more bits to regions with high detail/texture and fewer bits to flat areas. The VCE hardware analyzes macroblock variance to adaptively adjust quantization parameters.
Benefits:
- Better subjective quality at same bitrate
- Improved detail preservation
- Reduced blockiness in gradients
FFMPEG: -vbaq 1 Default: false (enable for better quality)