# H264 encoder

Media Blocks SDK .Net

The H264 encoder block is used for encoding files in MP4, MKV, and some other formats, as well as for network streaming using RTSP and HLS.

Use classes that implement the IH264EncoderSettings interface to set the parameters.

# Settings

# NVENCH264EncoderSettings

Nvidia GPUs H264 video encoder.

Platforms: Windows, Linux, macOS.

# AMFHEVCEncoderSettings

AMD/ATI GPUs H264 video encoder.

Platforms: Windows, Linux, macOS.

# QSVH264EncoderSettings

Intel GPU H264 video encoder.

Platforms: Windows, Linux, macOS.

# OpenH264EncoderSettings

Software CPU H264 encoder.

Platforms: Windows, macOS, Linux, iOS, Android.

# Block info

Name: H264EncoderBlock.

Pin direction Media type Pins count
Input Uncompressed video 1
Output H264 1

# The sample pipeline

graph LR;
    UniversalSourceBlock-->H264EncoderBlock;
    H264EncoderBlock-->MP4SinkBlock;

# Sample code

var pipeline = new MediaBlocksPipeline();

var filename = "test.mp4";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));

var h264EncoderBlock = new H264EncoderBlock(new NVENCH264EncoderSettings());
pipeline.Connect(fileSource.VideoOutput, h264EncoderBlock.Input);

var mp4SinkBlock = new MP4SinkBlock(new MP4SinkSettings(@"output.mp4"));
pipeline.Connect(h264EncoderBlock.Output, mp4SinkBlock.CreateNewInput(MediaBlockPadMediaType.Video));

await pipeline.StartAsync();

# Sample applications

# Platforms

Windows, macOS, Linux, iOS, Android.