Skip to main content

HTTP MJPEG live streaming output

MJPEG over HTTP: MJPEG (Motion JPEG) is a video format where each video frame or interlaced field of a digital video sequence is compressed separately as a JPEG image. Streaming it over HTTP allows for easy transmission of live or recorded video over the Internet without the need for complex player or server software, suitable for surveillance and webcam applications.

Use the class class constructor to set the network port.

Block info

Name: HTTPMJPEGLiveSinkBlock.

Pin directionMedia typePins count
Input videoUYVY, I420, NV12, NV21, YV12one
BGRA, BGRx, RGBA, RGBx

The sample pipeline

Sample code

The following code shows how to create a pipeline that streams a MJPEG video stream using HTTP.

// Pipeline
var pipeline = new MediaBlocksPipeline();

// video and audio sources
var virtualVideoSource = new VirtualVideoSourceSettings
{
Width = 1280,
Height = 720,
FrameRate = VideoFrameRate.FPS_25,
};

var videoSource = new VirtualVideoSourceBlock(virtualVideoSource);

// MJPEG HTTP sink
var sink = new HTTPMJPEGLiveSinkBlock(8080);
pipeline.Connect(videoSource.Output, sink.Input);

// Start
await pipeline.StartAsync();

Sample applications

Platforms

Windows, macOS, Linux, iOS, Android.