FFmpeg Tee Muxer vs Tee Protocol Explained
In FFmpeg, both the tee muxer and the tee
protocol are used to send a single input stream to multiple outputs
simultaneously, but they operate at different stages of the media
processing pipeline. The fundamental difference lies in the level at
which the stream splitting occurs: the tee muxer duplicates
data at the packet level before container encapsulation, allowing for
different output formats, whereas the tee protocol
duplicates the final, fully-muxed byte stream at the I/O layer to
identical destinations. Understanding this distinction is crucial for
optimizing streaming workflows and resource utilization.
The tee Muxer
The tee muxer operates at the muxing level of FFmpeg. It
receives encoded audio and video packets and duplicates them, sending
the copies to multiple separate muxers. Because it splits the stream
before containerization, you can write to different output formats and
apply different muxer-specific options to each destination.
- How it works: It acts as a master muxer that manages several slave muxers.
- Flexibility: You can output to different formats (e.g., RTMP stream, local MP4 file, and an HLS playlist) at the same time.
- Syntax example:
ffmpeg -i input.mp4 -map 0 -c:v libx264 -c:a aac -f tee "[f=flv]rtmp://live/stream|[f=mp4]archive.mp4" - Best Use Case: When you need to stream to a live platform (like Twitch or YouTube) while simultaneously saving a local copy of the broadcast in a different container format.
The tee Protocol
The tee protocol operates at the network and file I/O
layer, which is much lower in the pipeline than the muxer. It takes a
single, fully encapsulated byte stream from a single muxer and
replicates those exact bytes to multiple destinations.
- How it works: A single muxer packages the data, and
the
teeprotocol copies the raw output bytes to multiple network addresses or files. - Flexibility: There is no flexibility in format; all outputs must receive the exact same container and stream data.
- Syntax example:
ffmpeg -i input.mp4 -c:v libx264 -f mpegts "tee:udp://192.168.1.10:5000|udp://192.168.1.11:5000" - Best Use Case: Sending an identical MPEG-TS stream to multiple UDP or RTP destinations across a local network.
Summary of Differences
| Feature | tee Muxer |
tee Protocol |
|---|---|---|
| Pipeline Level | Muxer / Container Level | I/O / Protocol Level |
| Output Formats | Can be different (e.g., FLV and MP4) | Must be identical (e.g., UDP and UDP) |
| Configuration | High (per-output muxer options) | Low (identical byte replication) |
| CPU Overhead | Slightly higher due to multiple muxing processes | Extremely low, as muxing happens only once |