How to Stream to Multiple UDP Targets with FFmpeg Tee

Streaming a single media source to multiple destinations simultaneously is a common requirement in live broadcasting. This article provides a straightforward guide on how to configure and execute an FFmpeg command using the tee muxer to duplicate an input stream and send it to multiple UDP targets efficiently, minimizing CPU and network overhead by encoding the stream only once.

The FFmpeg Tee Command

To stream to multiple UDP targets, you use FFmpeg’s tee muxer. This muxer duplicates the output packets and sends them to the specified destinations.

Here is the standard command structure:

ffmpeg -re -i input.mp4 -c:v libx264 -c:a aac -f tee "[f=mpegts]udp://192.168.1.50:5000|[f=mpegts]udp://192.168.1.60:6000"

Command Breakdown

Streaming with Stream Copy (No Re-encoding)

If your input file or stream is already in a compatible format (like H.264 and AAC) and does not need transcoding, use the copy codec. This drastically reduces CPU usage:

ffmpeg -re -i input.mp4 -c copy -f tee "[f=mpegts]udp://239.0.0.1:1234|[f=mpegts]udp://239.0.0.2:1234"

Important Syntax Considerations