Skip to main content

MPEG-TS output

MPEG transport stream is a standard digital container format for the transmission and storage of audio, video, and PSIP data. It is used in broadcast systems such as DVB, ATSC, and IPTV.

Use the MPEGTSSinkSettings class to set the parameters.

Block info

Name: MPEGTSSinkBlock.

Pin directionMedia typePins count
Input audioaudio/mpeg [1,2,4]one or more
audio/x-lpcm
audio/x-ac3
audio/x-dts
audio/x-opus
Input videovideo/mpeg [1,2,4]one or more
video/x-dirac
video/x-h264
video/x-h265
Input subtitlemeta/x-klvone or more
subpicture/x-dvb
application/x-teletext

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 MPEGTSSinkBlock(new MPEGTSSinkSettings(@"output.ts"));
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.