Multimedia: FFMpeg

Streaming with FFMPEG

The simplest command line you can use to generate an RTP session composed by an audio stream and a video stream from an mp4 audio/video file is:

ffmpeg -re -i Videos/big_buck_bunny_720p_h264.mp4 \
-vcodec copy -an -f rtp rtp:// \
-vn -acodec copy -f rtp rtp://

Analysing this command line:

  • “-re” is needed to stream the audio and the video at the correct rate (instead of streaming as fast as possible)
  • “input.mpg” is the input file, to be streamed
  • “-vcodec copy” and “-acodec copy” mean the audio and the video tracks will be streamed without re-encoding them
  • “-f rtp” meand that the output format is RTP; we need one output stream for the video, and one for the audio. Hence, the first output has “-an” (no audio), the second output has “-vn” (no video)
  • The output protocol is RTP, hence, the output file names are “rtp://:”

After you start the ffmpeg program, it will print something like

o=- 0 0 IN IP4
s=No Name
t=0 0
a=tool:libavformat 58.17.101
m=video 9000 RTP/AVP 96
c=IN IP4
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=J0IAH5WQBQBbsBEAESqIAzf5gOBAAC3GwABbja974O0OGSQ=,KM48gA==; profile-level-id=42001F
m=audio 9002 RTP/AVP 97
c=IN IP4
a=rtpmap:97 MPEG4-GENERIC/48000/6
a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=11B0

You need to copy the SDP description (starting with “v=0”) in a .sdp file, that you will use to play the stream with vlc, ffplay, mplayer, or your favorite video player.

FFmpeg Docker containers
Other FFMpeg  examples

Streaming with VLC