Table of Contents

Class X265Settings

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

Provides configuration settings for x265 H.265/HEVC video encoding through FFMPEG.

public class X265Settings : BasicVideoSettings

Inheritance

Inherited Members

Remarks

x265 is the premier open-source H.265/HEVC encoder, providing significantly better compression efficiency than H.264. It typically achieves 25-50% better compression than x264 at equivalent quality levels, making it ideal for 4K, HDR, and bandwidth-constrained applications.

Key features of x265: - 25-50% better compression than H.264/x264 - Support for 4K, 8K, and HDR content - 10-bit and 12-bit color depth encoding - Advanced psychovisual optimizations - Parallel processing and SIMD optimizations - Comprehensive tuning options

Performance considerations: - 5-10x slower encoding than x264 - Higher CPU and memory requirements - Hardware acceleration recommended for real-time encoding - Preset selection has significant impact on speed

IMPORTANT: The FFMPEG executables provided with some SDKs may not include x265 due to licensing restrictions (x265 is GPL-licensed). You may need to build FFMPEG with --enable-libx265 or obtain a pre-built version that includes x265.

FFMPEG usage: ffmpeg -i input.mp4 -c:v libx265 -preset medium -crf 28 -tag:v hvc1 output.mp4

Constructors

X265Settings()

Initializes a new instance of the VisioForge.Core.Types.FFMPEGEXE.X265Settings class with recommended defaults.

public X265Settings()

Remarks

Default configuration optimized for H.265/HEVC encoding: - Encoder: x265 (libx265) - Profile: Main (8-bit, broad compatibility) - Level: 4.0 (supports 1080p@30fps) - Preset: Medium (balanced speed/quality) - Mode: CRF (constant quality) - Quantizer (CRF): 23 (note: consider increasing to 26-28 for typical x265 quality) - QuickTime Compatibility: Enabled - Zero-Latency: Disabled

Post-initialization adjustments for common scenarios:

For 4K/HDR content: - Set Profile to High10 for 10-bit - Increase Level to 5.0 or 5.1 - Consider Quantizer = 24-26 for 4K - Use Slow or Slower preset if time permits

For faster encoding: - Use Fast or VeryFast preset - Increase Quantizer to 28-30 - Reduce GOP size to 120-180

For maximum quality: - Use Slow or VerySlow preset - Set Quantizer to 20-24 - Increase B-frames to 6-8

Important: Remember that x265 encoding is significantly slower than x264. Budget 5-10x more encoding time compared to x264 at equivalent quality settings.

Properties

BFrames

Gets or sets the maximum number of consecutive B-frames.

public int BFrames { get; set; }

Property Value

int

Remarks

B-frames are even more beneficial in H.265 than H.264, providing better compression efficiency. H.265's improved prediction algorithms make B-frames more effective at reducing bitrate.

B-frame recommendations for x265: - 0: No B-frames (lowest latency, significantly larger files) - 3-4: Good balance (default for x265) - 4-6: Better compression for most content - 8: Maximum (diminishing returns, highest latency)

H.265 B-frame benefits: - 15-25% better compression than P-frames alone - Pyramid B-frame structure for even better efficiency - Less decode complexity increase compared to H.264

FFMPEG usage: -bf 4

GOPSize

Gets or sets the Group of Pictures (GOP) size.

public int GOPSize { get; set; }

Property Value

int

Remarks

GOP size for H.265 follows similar guidelines as H.264, though H.265's better intra prediction means slightly longer GOPs can be used without significant quality loss.

Recommended GOP sizes for H.265: - Live streaming: 60-120 frames (2-4 seconds @ 30fps) - VOD/4K streaming: 120-300 frames (4-10 seconds) - File archival: 250-500 frames (8-16 seconds)

For 4K and HDR content, longer GOPs are more acceptable due to: - Better H.265 intra prediction - Higher bitrates making I-frame overhead less significant - Typically viewed on larger screens where seeking is less frequent

FFMPEG usage: -g 250

Level

Gets or sets the H.265/HEVC level.

public H264Level Level { get; set; }

Property Value

H264Level

Remarks

NOTE: This property reuses H264Level enum values. For H.265, higher levels are required compared to H.264 for the same resolution due to different calculation methods.

Typical H.265 level requirements: - 1080p@30fps: Level 4.0 - 1080p@60fps: Level 4.1 - 4K@30fps: Level 5.0 - 4K@60fps: Level 5.1

See VisioForge.Core.Types.FFMPEGEXE.H264Level for available level options.

Mode

Gets or sets the x265 rate control mode.

public X264Mode Mode { get; set; }

Property Value

X264Mode

Remarks

NOTE: This property reuses X264Mode enum. The rate control modes work similarly in x265 but with different default parameters optimized for HEVC.

For H.265/HEVC encoding, CRF values typically need to be 2-4 points higher than H.264 to achieve similar visual quality due to different encoder behavior.

Default: CRF (Constant Rate Factor)

See VisioForge.Core.Types.FFMPEGEXE.X264Mode for detailed information about each rate control mode.

Preset

Gets or sets the x265 encoding preset.

public X264Preset Preset { get; set; }

Property Value

X264Preset

Remarks

Presets control the trade-off between encoding speed and compression efficiency. For x265, this trade-off is more dramatic than x264: slower presets provide significantly better compression but take much longer to encode.

Speed vs Quality (relative to Medium preset): - UltraFast: 8x faster, -25% compression efficiency - VeryFast: 4x faster, -15% compression efficiency - Fast: 2x faster, -10% compression efficiency - Medium: Baseline (default) - Slow: 2x slower, +10% compression efficiency - Slower: 4x slower, +15% compression efficiency - VerySlow: 8x slower, +20% compression efficiency

Default: Medium (good balance for most use cases)

Note: This property reuses X264Preset enum. The preset names are the same for both x264 and x265, though the exact encoding parameters differ.

See VisioForge.Core.Types.FFMPEGEXE.X264Preset for detailed preset descriptions.

PresetCustom

Gets or sets the custom preset string when using advanced x265 options.

public string PresetCustom { get; set; }

Property Value

string

Remarks

Allows specification of a custom preset/tune combination or advanced x265 parameters not exposed through the standard interface.

Set VisioForge.Core.Types.FFMPEGEXE.X265Settings.Preset to X264Preset.None before using this property.

Example custom presets for x265: - "slow,tune=grain": For film with heavy grain - "medium,tune=animation": For animated content - "fast,tune=fastdecode": For faster playback - "veryslow,limit-tu=1": Maximum compression

FFMPEG usage: -preset [custom_string] -x265-params [params]

Profile

Gets or sets the H.265/HEVC profile.

public H264Profile Profile { get; set; }

Property Value

H264Profile

Remarks

NOTE: This property reuses H264Profile enum values but applies to H.265/HEVC encoding. The profile names (Main, Main10, etc.) have similar meanings in H.265 context.

Common H.265 profiles: - Main: 8-bit 4:2:0, standard for most content - Main10: 10-bit 4:2:0, for HDR and high-quality content - Main422-10: 10-bit 4:2:2, professional broadcast

See VisioForge.Core.Types.FFMPEGEXE.H264Profile for available profile options.

Quantizer

Gets or sets the Constant Rate Factor (CRF) quantizer value for x265.

public int Quantizer { get; set; }

Property Value

int

Remarks

CRF scale for x265 (0-51): - 0: Lossless (mathematically perfect, extremely large files) - 20-22: Visually lossless (indistinguishable from source) - 24-28: High quality (28 is default for x265, good for most content) - 29-32: Good quality (suitable for web streaming) - 33-38: Acceptable quality (noticeable compression) - 39-51: Poor to very poor quality (not recommended)

Important: x265 CRF scale is shifted compared to x264: - x264 CRF 23 ≈ x265 CRF 28 (similar visual quality) - x264 CRF 18 ≈ x265 CRF 22 (visually lossless)

The difference is due to x265's more efficient compression and different quality calculation methods. Always start 4-5 points higher than you would use for x264.

Default: 23 (note: x265 default is 28, this uses 23 for consistency with x264 settings) Recommended range for x265: 22-32

FFMPEG usage: -crf 28

QuickTime_Compatibility

Gets or sets a value indicating whether Apple QuickTime compatibility is enabled.

public bool QuickTime_Compatibility { get; set; }

Property Value

bool

Remarks

Ensures H.265/HEVC video compatibility with Apple QuickTime Player and Apple devices. QuickTime supports HEVC but has specific requirements for color space and container.

QuickTime HEVC requirements: - YUV planar color space with 4:2:0 chroma subsampling (yuv420p or yuv420p10le) - Proper codec tag in MP4 container (hvc1 preferred) - Compliant MP4 container structure

FFMPEG enforces: -pix_fmt yuv420p (8-bit) or -pix_fmt yuv420p10le (10-bit HDR)

Important for H.265: - macOS High Sierra (10.13) and later support HEVC - iOS 11 and later support HEVC - Hardware decode acceleration on Apple Silicon and recent Intel Macs - HDR10 support requires 10-bit color depth and specific metadata

Default: true (recommended for broad Apple ecosystem compatibility)

WebFastStart

Gets or sets a value indicating whether fast start mode is enabled for web playback.

public bool WebFastStart { get; set; }

Property Value

bool

Remarks

Moves the MP4 metadata to the beginning of the file for progressive download and streaming playback. Essential for web video delivery.

FFMPEG usage: -movflags +faststart

Note: For H.265 in MP4 container, also ensure proper codec tag is set (hvc1 or hev1) for browser compatibility. Some browsers require hvc1 tag for H.265 playback.

ZeroTolerance

Gets or sets a value indicating whether zero-latency mode is enabled for streaming.

public bool ZeroTolerance { get; set; }

Property Value

bool

Remarks

Optimizes x265 for real-time streaming by disabling features that require frame buffering. Similar to x264's tune=zerolatency but for HEVC.

Note: Real-time H.265 encoding is extremely CPU-intensive. Zero-latency mode helps but encoding 1080p or higher at real-time speeds typically requires: - Very fast presets (ultrafast, superfast) - Modern multi-core CPU (8+ cores) - Or hardware acceleration (NVENC HEVC, QSV HEVC)

Consider using hardware-accelerated HEVC encoders (hevc_nvenc, hevc_qsv, hevc_amf) instead of x265 for live streaming applications.

Default: false