FFmpeg Tee Muxer vs Tee Protocol: Key Differences

In FFmpeg, both the tee muxer and the tee protocol are designed to output content to multiple destinations simultaneously without re-encoding, but they operate at fundamentally different layers of the media pipeline. This article breaks down how the tee muxer works at the container level to send media streams to diverse formats and targets, how the tee protocol duplicates identical raw byte streams at the network and file I/O layer, and how to choose the right tool for your workflow.


Operating Layers: Container vs. I/O

The core difference between the two approaches comes down to where in the FFmpeg pipeline the duplication occurs:

  • tee muxer (-f tee): Operates at the muxing (packet) layer. It receives encoded packets (video, audio, subtitles) from the encoder or demuxer and passes them into multiple, independent output muxers.
  • tee protocol (tee:): Operates at the protocol (byte/transport) layer. It receives a single, already-muxed byte stream and clones the exact byte sequence to multiple outputs.

FFmpeg tee Muxer

The tee muxer is invoked as an output format using the -f tee flag. Because it controls the muxing process for each destination, it provides significant flexibility.

Key Capabilities

  • Different Container Formats: You can write to an MP4 file locally while simultaneously packaging the same streams into an FLV container for an RTMP stream.
  • Per-Output Bitstream Filters (BSFs): You can apply specific bitstream modifications (such as h264_mp4toannexb) to one destination without affecting another.
  • Per-Output Flags and Options: You can specify custom muxer options, metadata, or buffering behaviors for each individual target.
  • Stream Selection: You can selectively choose which streams (e.g., video, primary audio, secondary audio) go to which destination.

Example Syntax

ffmpeg -i input.mp4 -c:v copy -c:a copy \
-f tee "[f=flv]rtmp://live.example.com/app/stream|[movflags=+faststart]local_archive.mp4"

In this command, the input stream is packaged into FLV for network streaming and MP4 with the faststart flag for local storage, all within a single encoding process.


FFmpeg tee Protocol

The tee protocol is an I/O wrapper invoked in the output URL rather than through the format flag. It takes a single output stream that has already been generated by a single muxer and mirrors the identical bytes to multiple destinations.

Key Capabilities

  • Exact Byte Duplication: Every destination receives the exact same bytes. There is no possibility to alter containers, bitstream filters, or packet headers between outputs.
  • Network and I/O Multiplexing: It is typically used to duplicate network streams (such as UDP, TCP, or HTTP) or write identical files to multiple storage locations.
  • Lower Overhead: Because it bypasses running multiple muxing instances, it incurs slightly less CPU and memory overhead compared to running multiple full muxers in the tee muxer.

Example Syntax

ffmpeg -i input.mp4 -c:v copy -c:a copy -f mpegts \
"tee:udp://239.0.0.1:1234|udp://239.0.0.2:1234"

In this command, FFmpeg creates a single MPEG-TS stream and writes the identical raw UDP payload to two different multicast IP addresses.


Comparison Summary

Feature tee Muxer (-f tee) tee Protocol (tee:)
Pipeline Level Muxer / Container layer Transport / I/O layer
Containers Can be different for each target Must be identical for all targets
Stream Mapping Can select specific streams per target Identical across all targets
Bitstream Filters Configurable per target Applied globally or not at all
Typical Use Cases Live streaming + local archiving, writing HLS + MP4 simultaneously Duplicating UDP/RTP feeds, mirroring identical files

Use the tee muxer when your destinations require different file formats, protocols with specific container requirements, or separate stream mappings. Use the tee protocol when you simply need to deliver an identical byte stream to two or more network endpoints or storage locations.