Skip to main content

SRT (MPEG-TS) streaming

Secure Reliable Transport (SRT) is an open-source streaming protocol designed to deliver low-latency video across unpredictable networks like the Internet. Developed by Haivision, SRT uses encryption and error-correction mechanisms to ensure secure and reliable data transmission. By adapting to changing network conditions in real time, it minimizes jitter, packet loss, and bandwidth fluctuations. SRT supports features like packet retransmission and congestion control, making it ideal for live video streaming, remote contribution, and other latency-sensitive applications in broadcasting and media.

Video and audio streams will be muxed into an MPEG-TS container and sent over the SRT protocol.

Use the SRTSinkSettings class to set the parameters.

Block info

Name: SRTMPEGTSSinkBlock.

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

// 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);

var virtualAudioSource = new VirtualAudioSourceSettings
{
Channels = 2,
SampleRate = 44100,
};

var audioSource = new VirtualAudioSourceBlock(virtualAudioSource);

// H264/AAC encoders
var h264Encoder = new H264EncoderBlock(new OpenH264EncoderSettings());
h264Encoder.Settings.ParseStream = false; // we have to disable parsing for SRT for H264 and HEVC encoders
var aacEncoder = new AACEncoderBlock();

pipeline.Connect(videoSource.Output, h264Encoder.Input);
pipeline.Connect(audioSource.Output, aacEncoder.Input);

// Sink
var sink = new SRTMPEGTSSinkBlock(new SRTSinkSettings() { Uri = "srt://:8888" });
pipeline.Connect(h264Encoder.Output, sink.CreateNewInput(MediaBlockPadMediaType.Video));
pipeline.Connect(aacEncoder.Output, sink.CreateNewInput(MediaBlockPadMediaType.Audio));

// Start
await pipeline.StartAsync();

Sample applications

Platforms

Windows, macOS, Linux, iOS, Android.