Skip to main content

MPEG-PS output

MPEG-PS (MPEG Program Stream): A standard format for storing video, audio, and metadata multiplexed into a single stream. It is widely used in systems and applications requiring synchronized audio and video playback, such as DVDs.

Use the constructor to set the output file name.

Block info

Name: MPEGPSSinkBlock.

Pin directionMedia typePins count
Input audioaudio/mpeg [1,2,4]one or more
audio/x-lpcm
Input videovideo/mpeg [1,2,4]one or more
video/x-dirac
video/x-h264

The sample pipeline

Sample code

var pipeline = new MediaBlocksPipeline();

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

var aacEncoderBlock = new AACEncoderBlock(new MFAACEncoderSettings() { Bitrate = 192 });
pipeline.Connect(fileSource.AudioOutput, aacEncoderBlock.Input);

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

var tsSinkBlock = new MPEGPSSinkBlock(@"output.mpg");
pipeline.Connect(h264EncoderBlock.Output, tsSinkBlock.CreateNewInput(MediaBlockPadMediaType.Video));
pipeline.Connect(aacEncoderBlock.Output, tsSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio));

await pipeline.StartAsync();

Platforms

Windows, macOS, Linux, iOS, Android.