Contents

Introduction

The following example command lines, that are usually written in one line, have been split into multiple lines, using the new-line delimiter character "\" for more clarity. So, if the example shows something like this:

ffmpeg -i input \
-acodec .. \
-vcodec .. \
output1

that means the actual command line, typed in the shell, would be:

ffmpeg -i input -acodec .. -vcodec .. output1

Different parallel outputs

FFmpeg supports multiple outputs created out of the same input(s). The usual way to accomplish this is:

Duplicate outputs

But, what if you want to have duplicate outputs of your encoding? For example, when you are streaming a live audio/video and want to save a duplicate of that stream into the file at the same time. You don't want to encode twice, that wastes cpu.

Tee pseudo-muxer

The tee pseudo-muxer was added to ffmpeg on 2013-02-03, and allows you to duplicate the output to multiple files, on a single instance of ffmpeg.

The above outputs an MKV file, and a UDP stream. Streams are separated by the | symbol. Options can be applied to an individual output: [f=mpegts] is equivalent to -f mpegts in a normal ffmpeg command-line. Multiple options can be separated with a :, which means that any : have to be escaped (so use \:).

Piped processes

Older versions of ffmpeg can also do this, using 2 piped processes, where the first process is used to encode the stream(s) and second process is used to duplicate that to several outputs.

Parallel Encoding

Another option is to output from FFmpeg to "-" then to pipe that to a "tee" command, which can send it to multiple other processes, for instance 2 different other ffmpeg processes for encoding (this may save time, as if you do different encodings, and do the encoding in 2 different simultaneous processes, it might do encoding more in parallel than elsewise). Un benchmarked, however, see also ​here.