Skip to main content

Facebook Live streaming

Facebook Live supports RTMP (Real-Time Messaging Protocol), a protocol for streaming audio, video, and data over the Internet. RTMP is used to maintain low-latency connections and deliver high-quality live broadcasts on Facebook, making it a popular choice for streaming live events and interactions.

Use the FacebookLiveSinkSettings class to set the parameters.

Block info

Name: FacebookLiveSinkBlock.

Pin directionMedia typePins count
Input audioaudio/x-aacone
audio/x-mp3
Input videovideo/x-h264one
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);

// Facebook Live sink
var facebookSink = new FacebookLiveSinkBlock(new FacebookLiveSinkSettings("long streaming key"));
pipeline.Connect(h264Encoder.Output, facebookSink.CreateNewInput(MediaBlockPadMediaType.Video));
pipeline.Connect(aacEncoder.Output, facebookSink.CreateNewInput(MediaBlockPadMediaType.Audio));

// Start
await pipeline.StartAsync();

Sample applications

Platforms

Windows, macOS, Linux, iOS, Android.