RTMP streaming
RTMP (Real-Time Messaging Protocol)
: Developed by Adobe, RTMP is a protocol used for streaming audio, video, and data over the Internet, optimized for high-performance transmission. It enables efficient, low-latency communication, commonly used in live broadcasting like sports events and concerts.
Use the RTMPSinkSettings
class to set the parameters.
Block info
Name: RTMPSinkBlock.
Pin direction | Media type | Pins count |
---|---|---|
Input audio | audio/mpeg [1,2,4] | one |
audio/x-adpcm | ||
PCM [U8, S16LE] | ||
audio/x-speex | ||
audio/x-mulaw | ||
audio/x-alaw | ||
audio/x-nellymoser | ||
Input video | video/x-h264 | one |
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());
var aacEncoder = new AACEncoderBlock();
pipeline.Connect(videoSource.Output, h264Encoder.Input);
pipeline.Connect(audioSource.Output, aacEncoder.Input);
// RTMP sink
var sink = new RTMPSinkBlock(new RTMPSinkSettings());
pipeline.Connect(h264Encoder.Output, sink.CreateNewInput(MediaBlockPadMediaType.Video));
pipeline.Connect(aacEncoder.Output, sink.CreateNewInput(MediaBlockPadMediaType.Audio));
// Start
await pipeline.StartAsync();
Platforms
Windows, macOS, Linux, iOS, Android.