YouTube Live streaming
YouTube supports RTMP (Real-Time Messaging Protocol) for live streaming, allowing content creators to broadcast live video and audio streams over the internet with minimal delay. This protocol is vital for delivering smooth, high-quality live feeds that are suitable for everything from personal vlogging to professional broadcasts.
Use the YouTubeSinkSettings
class to set the parameters.
Block info
Name: YouTubeSinkBlock.
Pin direction | Media type | Pins count |
---|---|---|
Input audio | audio/x-aac | one |
audio/x-mp3 | ||
Input video | video/x-h264 | one |
video/x-h265 |
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);
// YouTube Live sink
var sink = new YouTubeSinkBlock(new YouTubeSinkSettings("long streaming key"));
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.