FFmpeg is a free open-source software project with command-line tools for handling video, audio, and other multimedia. Depending on your workflow, you may want to broadcast over WebRTC from a file on disk or another Real-time Streaming Protocol (RTSP). FFmpeg enables you to originate the broadcast from a
ffmpeg command that forwards the stream over RTMP to the Dolby.io real-time streaming servers for global low-delay distribution.
See the official ffmpeg.org documentation for installation instructions and additional support.
If you haven't already, begin by following the Getting Started tutorial to create a Dolby.io application and start your first broadcast.
In order to broadcast with RTMP, you will need to have your RTMP publish path and RTMP publish stream name available.
See the RTMP Broadcast Guide for details on how to retrieve these values. They will be referenced as environment variables
$RTMP_PUBLISH_STREAM_NAME in the examples below.
You will need to substitute the
$RTMP_PUBLISH_PATH that is appropriate for the shell environment and operating system you are using.
ffmpeg -re -stream_loop -1 -i $VIDEO_FILE_PATH \ -vcodec libx264 \ -preset veryfast \ -bf 0 -g 60 \ -vb 3000k \ -vprofile baseline \ -level 3.0 \ -acodec aac \ -ab 96000 -ar 48000 -ac 2 \ -strict experimental \ -f flv \ -rtmp_playpath $RTMP_PUBLISH_STREAM_NAME \ -rtmp_live live $RTMP_PUBLISH_PATH
A few notes about these recommended settings.
|-stream_loop -1||Loop the video indefinitely|
|-vcodec libx264||H.264 video codec|
|-vb 3000k||Video Bitrate setting of 3Kbps|
|-acodec aac||AAC audio codec|
|-ac 2||Audio channels for stereo|
|-ab 96000||Audio Bitrate setting of 96Kbps|
|-ar 48000||Audio Sample Rate of 48Kbps|
|-bf 0||Disable bframes|
|-g 60||Group of pictures (GOP) size|
|-f flv||Format as flash video|
|-preset veryfast||Video encoding speed to compression ratio preset|
|-vprofile baseline -level 3.0||H.264 profile and level that specifies maximum decoding speed, frame size, and bit rate|
You can then watch this stream from a playback viewer.
Support for Real-time Streaming Protocol (RTSP) can be done with
ffmpeg by changing the input source. All of the other parameters are consistent with streaming a media file from disk.
ffmpeg -re -i rtsp://98.116.xx.xx:5545/axis-media/media.amp \ -vcodec libx264 \ -preset veryfast \ -bf 0 -g 60 \ -vb 3000k \ -vprofile baseline \ -level 3.0 \ -acodec aac \ -ab 96000 -ar 48000 -ac 2 \ -strict experimental \ -f flv \ -rtmp_playpath $RTMP_PUBLISH_STREAM_NAME \ -rtmp_live live $RTMP_PUBLISH_PATH
These examples were verified with
ffmpeg version 6.0 on MacOS.
> ffmpeg -version ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers built with Apple clang version 14.0.3 (clang-1403.0.22.14.1)
If you are using a different version or operating system please include these details when reporting any issues.
If you experience stutter in your streaming video, make sure you are using the options:
-vprofile baseline and
You can also modify the
-preset to adjust the compression speed to quality ratio.
This guide covered broadcasting with
ffmpeg. To test and view the stream you can use the dashboard or any of the other playback methods.
Updated 4 months ago