Skip to main content

MJPEG encoder

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 directionMedia typePins count
InputUncompressed video1
OutputMJPEG1

The sample pipeline

Sample code

var pipeline = new MediaBlocksPipeline(false);

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.