# MJPEG encoder

Media Blocks SDK .Net

MJPEG (Motion JPEG): A video compression format where each frame of video is separately compressed into a JPEG image. This technique is straightforward and results in no interframe compression, making it ideal for situations where frame-specific editing or access is required, such as in surveillance and medical imaging. Use classes that implement the IH264EncoderSettings interface to set the parameters.

# Settings

# MJPEGEncoderSettings

Default MJPEG encoder. CPU encoder.

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

# QSVMJPEGEncoderSettings

Intel GPUs MJPEG encoder.

Platforms: Windows, Linux, macOS.

# Block info

Name: MJPEGEncoderBlock.

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

# The sample pipeline

graph LR;
    UniversalSourceBlock-->MJPEGEncoderBlock;
    MJPEGEncoderBlock-->AVISinkBlock;

# Sample code

var pipeline = new MediaBlocksPipeline();

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

var videoEncoderBlock = new MJPEGEncoderBlock(new MJPEGEncoderSettings());
pipeline.Connect(fileSource.VideoOutput, videoEncoderBlock.Input);

var aviSinkBlock = new AVISinkBlock(new AVISinkSettings(@"output.avi"));
pipeline.Connect(videoEncoderBlock.Output, aviSinkBlock.CreateNewInput(MediaBlockPadMediaType.Video));

await pipeline.StartAsync();

# Platforms

Windows, macOS, Linux, iOS, Android.