Skip to main content

H264 Encoders

This document provides detailed information about available H264 encoders, their features, rate control options, and usage examples.

For Windows-only engines check the MP4 output page.

Overview

The following H264 encoders are available:

  1. AMD AMF H264 Encoder (GPU-accelerated)
  2. NVIDIA NVENC H264 Encoder (GPU-accelerated)
  3. Intel QSV H264 Encoder (GPU-accelerated)
  4. OpenH264 Encoder (Software)
  5. Apple Media H264 Encoder (Hardware-accelerated for Apple devices)
  6. VAAPI H264 Encoder (Linux hardware acceleration)
  7. Various OMX-based encoders (Platform-specific)

AMD AMF H264 Encoder

AMD's Advanced Media Framework (AMF) provides hardware-accelerated encoding on AMD GPUs.

Key Features

  • Hardware-accelerated encoding
  • Multiple preset options (Balanced, Speed, Quality)
  • Configurable GOP size
  • CABAC entropy coding support
  • Various rate control methods

Rate Control Options

public enum AMFH264EncoderRateControl
{
Default = -1, // Default, depends on usage
CQP = 0, // Constant QP
CBR = 1, // Constant bitrate
VBR = 2, // Peak constrained VBR
LCVBR = 3 // Latency Constrained VBR
}

Sample Usage

var settings = new AMFH264EncoderSettings
{
Bitrate = 5000, // 5 Mbps
CABAC = true,
RateControl = AMFH264EncoderRateControl.CBR,
Preset = AMFH264EncoderPreset.Quality,
Profile = AMFH264EncoderProfile.Main,
Level = AMFH264EncoderLevel.Level4_2,
GOPSize = 30
};

var encoder = new H264EncoderBlock(settings);

NVIDIA NVENC H264 Encoder

NVIDIA's hardware-based video encoder provides efficient H264 encoding on NVIDIA GPUs.

Key Features

  • Hardware-accelerated encoding
  • B-frame support
  • Adaptive quantization
  • Multiple reference frames
  • Weighted prediction
  • Look-ahead support

Rate Control Options

Inherited from NVENCBaseEncoderSettings with additional H264-specific options:

  • Constant Bitrate (CBR)
  • Variable Bitrate (VBR)
  • Constant QP (CQP)
  • Quality-based VBR

Sample Usage

var settings = new NVENCH264EncoderSettings
{
Bitrate = 5000,
MaxBitrate = 8000,
RCLookahead = 20,
BFrames = 2,
Profile = NVENCH264Profile.High,
Level = NVENCH264Level.Level4_2,
TemporalAQ = true
};

var encoder = new H264EncoderBlock(settings);

Intel Quick Sync Video (QSV) H264 Encoder

Intel's hardware-based video encoder available on Intel processors with integrated graphics.

Key Features

  • Hardware-accelerated encoding
  • Low latency mode
  • Multiple rate control methods
  • B-frame support
  • Intelligent rate control options

Rate Control Options

public enum QSVH264EncRateControl
{
CBR = 1, // Constant Bitrate
VBR = 2, // Variable Bitrate
CQP = 3, // Constant Quantizer
AVBR = 4, // Average Variable Bitrate
LA_VBR = 8, // Look Ahead VBR
ICQ = 9, // Intelligent CQP
VCM = 10, // Video Conferencing Mode
LA_ICQ = 11, // Look Ahead ICQ
LA_HRD = 13, // HRD compliant LA
QVBR = 14 // Quality-defined VBR
}

Sample Usage

var settings = new QSVH264EncoderSettings
{
Bitrate = 5000,
MaxBitrate = 8000,
RateControl = QSVH264EncRateControl.VBR,
Profile = QSVH264EncProfile.High,
Level = QSVH264EncLevel.Level4_2,
LowLatency = true,
BFrames = 2
};

var encoder = new H264EncoderBlock(settings);

OpenH264 Encoder

Cisco's open-source H264 software encoder.

Key Features

  • Software-based encoding
  • Multiple complexity levels
  • Scene change detection
  • Adaptive quantization
  • Denoising support

Rate Control Options

public enum OpenH264RCMode
{
Quality = 0, // Quality mode
Bitrate = 1, // Bitrate mode
Buffer = 2, // Buffer based
Off = -1 // Rate control off
}

Sample Usage

var settings = new OpenH264EncoderSettings
{
Bitrate = 5000,
RateControl = OpenH264RCMode.Bitrate,
Profile = OpenH264Profile.Main,
Level = OpenH264Level.Level4_2,
Complexity = OpenH264Complexity.Medium,
EnableDenoise = true,
SceneChangeDetection = true
};

var encoder = new H264EncoderBlock(settings);

Apple Media H264 Encoder

Hardware-accelerated encoder for Apple platforms.

Key Features

  • Hardware acceleration on Apple devices
  • Real-time encoding support
  • Frame reordering options
  • Quality-based encoding

Sample Usage

var settings = new AppleMediaH264EncoderSettings
{
Bitrate = 5000,
AllowFrameReordering = true,
Quality = 0.8,
Realtime = true
};

var encoder = new H264EncoderBlock(settings);

VAAPI H264 Encoder

Video Acceleration API encoder for Linux systems.

Key Features

  • Hardware acceleration on Linux
  • Multiple profile support
  • Trellis quantization
  • B-frame support
  • Various rate control methods

Rate Control Options

public enum VAAPIH264RateControl
{
CQP = 1, // Constant QP
CBR = 2, // Constant bitrate
VBR = 4, // Variable bitrate
VBRConstrained = 5, // Constrained VBR
ICQ = 7, // Intelligent CQP
QVBR = 8 // Quality-defined VBR
}

Sample Usage

var settings = new VAAPIH264EncoderSettings
{
Bitrate = 5000,
RateControl = VAAPIH264RateControl.CBR,
Profile = VAAPIH264EncoderProfile.Main,
MaxBFrames = 2,
Trellis = true,
CABAC = true
};

var encoder = new H264EncoderBlock(settings);

OpenMAX (OMX) H264 Encoders Guide

OpenMAX (OMX) is a royalty-free cross-platform API that provides comprehensive streaming media codec and application portability by enabling accelerated multimedia components to be developed, integrated and programmatically accessed across multiple operating systems and silicon platforms.

OMX Google H264 Encoder

This is a baseline implementation primarily targeted at Android platforms.

var settings = new OMXGoogleH264EncoderSettings();
// Configure via Properties dictionary
settings.Properties["some_key"] = "value";
settings.ParseStream = true; // Enable stream parsing (disable for SRT)

Key characteristics:

  • Generic implementation
  • Suitable for most Android devices
  • Configurable through properties dictionary
  • Minimal direct parameter exposure for maximum compatibility

OMX Qualcomm H264 Encoder

Optimized for Qualcomm Snapdragon platforms, this encoder leverages hardware acceleration capabilities.

var settings = new OMXQualcommH264EncoderSettings
{
Bitrate = 6_000, // 6 Mbps
IFrameInterval = 2, // Keyframe every 2 seconds
ParseStream = true // Enable stream parsing
};

Key features:

  • Direct bitrate control
  • I-frame interval management
  • Hardware acceleration on Qualcomm platforms
  • Additional properties available through dictionary

OMX Exynos H264 Encoder

Specifically designed for Samsung Exynos platforms:

var settings = new OMXExynosH264EncoderSettings();
// Configure platform-specific options
settings.Properties["quality_level"] = "high";
settings.Properties["hardware_acceleration"] = "true";

Characteristics:

  • Samsung hardware optimization
  • Flexible configuration through properties
  • Hardware acceleration support
  • Platform-specific optimizations

OMX SPRD H264 Encoder

Designed for Spreadtrum (UNISOC) platforms:

var settings = new OMXSPRDH264EncoderSettings
{
Bitrate = 6_000, // Target bitrate
IFrameInterval = 2, // GOP size in seconds
ParseStream = true // Stream parsing flag
};

Features:

  • Hardware acceleration for SPRD chips
  • Direct bitrate control
  • Keyframe interval management
  • Additional platform-specific properties

Common Properties and Usage

All OMX encoders share some common characteristics:

// Common interface implementation
public interface IH264EncoderSettings
{
bool ParseStream { get; set; }
KeyFrameDetectedDelegate KeyFrameDetected { get; set; }
H264EncoderType GetEncoderType();
MediaBlock CreateBlock();
}

Properties dictionary usage:

// Generic way to set platform-specific options
settings.Properties["hardware_acceleration"] = "true";
settings.Properties["quality_preset"] = "balanced";
settings.Properties["thread_count"] = "4";

Best Practices

  1. Encoder Selection

    • Use hardware encoders (AMD, NVIDIA, Intel) when available for better performance
    • Fall back to OpenH264 when hardware encoding is not available
    • Use platform-specific encoders (Apple Media, VAAPI) when targeting specific platforms
  2. Rate Control Selection

    • Use CBR for streaming applications where consistent bitrate is important
    • Use VBR for offline encoding where quality is more important than bitrate consistency
    • Use CQP for highest quality when bitrate is not a concern
    • Consider using look-ahead options for better quality when latency is not critical
  3. Performance Optimization

    • Adjust GOP size based on content type (smaller for high motion, larger for static content)
    • Enable CABAC for better compression efficiency when latency is not critical
    • Use appropriate profile and level for target devices
    • Consider B-frames for better compression but be aware of latency impact
  4. Platform Detection:

if (OMXSPRDH264EncoderSettings.IsAvailable())
{
// Use SPRD encoder
}
else if (OMXQualcommH264EncoderSettings.IsAvailable())
{
// Fall back to Qualcomm
}
else
{
// Fall back to Google implementation
}

Platform-Specific Considerations

  1. Qualcomm Platforms:
  • Best performance with native bitrate settings
  • Optimal for streaming when I-frame interval is 2-3 seconds
  • Hardware acceleration should be enabled when possible
  1. Exynos Platforms:
  • Properties dictionary offers more fine-grained control
  • Consider using platform-specific quality presets
  • Monitor hardware acceleration status
  1. SPRD Platforms:
  • Keep bitrate within platform capabilities
  • Use I-frame interval appropriate for content type
  • Consider memory constraints when setting properties
  1. General OMX:
  • Always test on target hardware
  • Monitor encoder performance metrics
  • Have fallback options ready
  • Consider power consumption impact