Stream Stereo as Two Mono RTP Streams with FFmpeg
This guide explains how to use FFmpeg to split a stereo audio input and broadcast it as two separate, independent mono RTP (Real-time Transport Protocol) streams. You will learn the exact command-line syntax, how the audio filtergraph separates the channels, and how to configure the destination ports for receiver playback.
The FFmpeg Command
To split a stereo source and stream it to two different RTP destinations, use the following command:
ffmpeg -i input.mp3 -filter_complex "[0:a]channelsplit=channel_layout=stereo[left][right]" \
-map "[left]" -c:a pcm_s16be -f rtp rtp://127.0.0.1:5004 \
-map "[right]" -c:a pcm_s16be -f rtp rtp://127.0.0.1:5006Command Breakdown
-i input.mp3: Specifies the input stereo audio file or stream.-filter_complex "[0:a]channelsplit=channel_layout=stereo[left][right]": This is the core filter. It takes the first input’s audio ([0:a]), uses thechannelsplitfilter to extract the stereo channels, and labels the output streams as[left]and[right].-map "[left]": Directs the extracted left channel to the first output.-map "[right]": Directs the extracted right channel to the second output.-c:a pcm_s16be: Encodes the audio.pcm_s16be(signed 16-bit Big-Endian PCM) is a standard uncompressed format highly compatible with RTP. You can replace this with other codecs likelibopusorlibmp3lameif bandwidth compression is required.-f rtp: Forces the output format to RTP.rtp://127.0.0.1:5004andrtp://127.0.0.1:5006: Defines the destination IP address and unique port numbers for each mono stream. Ensure you use even port numbers as RTP standards reserve odd ports for RTCP control packets.
Accessing the Streams (SDP Files)
RTP streams require a Session Description Protocol (SDP) file for receivers (like VLC or FFplay) to understand the audio encoding and port mapping.
FFmpeg displays the SDP configuration in the console output when you
run the command. To capture and save these configurations directly to
files for your players, add the -sdp_file option:
ffmpeg -i input.mp3 -filter_complex "[0:a]channelsplit=channel_layout=stereo[left][right]" \
-map "[left]" -c:a pcm_s16be -f rtp -sdp_file left.sdp rtp://127.0.0.1:5004 \
-map "[right]" -c:a pcm_s16be -f rtp -sdp_file right.sdp rtp://127.0.0.1:5006Receivers can then play the independent mono streams by opening the
generated left.sdp or right.sdp files.