fifo
The fifo pseudo-muxer allows the separation of encoding and muxing by using first-in-first-out queue and running the actual muxer in a separate thread. This is especially useful in combination with the tee muxer and can be used to send data to several destinations with different reliability/writing speed/latency.
API users should be aware that callback functions (interrupt_callback, io_open and io_close) used within its AVFormatContext must be thread-safe.
The behavior of the fifo muxer if the queue fills up or if the output fails is selectable,
- output can be transparently restarted with configurable delay between retries based on real time or time of the processed stream.
- encoding can be blocked during temporary failure, or continue transparently dropping packets in case fifo queue fills up.
- 'fifo_format'
-
Specify the format name. Useful if it cannot be guessed from the output name suffix.
- 'queue_size'
-
Specify size of the queue (number of packets). Default value is 60.
- 'format_opts'
-
Specify format options for the underlying muxer. Muxer options can be specified as a list of key=value pairs separated by ':'.
- 'drop_pkts_on_overflow bool'
-
If set to 1 (true), in case the fifo queue fills up, packets will be dropped rather than blocking the encoder. This makes it possible to continue streaming without delaying the input, at the cost of omitting part of the stream. By default this option is set to 0 (false), so in such cases the encoder will be blocked until the muxer processes some of the packets and none of them is lost.
- 'attempt_recovery bool'
-
If failure occurs, attempt to recover the output. This is especially useful when used with network output, since it makes it possible to restart streaming transparently. By default this option is set to 0 (false).
- 'max_recovery_attempts'
-
Sets maximum number of successive unsuccessful recovery attempts after which the output fails permanently. By default this option is set to 0 (unlimited).
- 'recovery_wait_time duration'
-
Waiting time before the next recovery attempt after previous unsuccessful recovery attempt. Default value is 5 seconds.
- 'recovery_wait_streamtime bool'
-
If set to 0 (false), the real time is used when waiting for the recovery attempt (i.e. the recovery will be attempted after at least recovery_wait_time seconds). If set to 1 (true), the time of the processed stream is taken into account instead (i.e. the recovery will be attempted after at least recovery_wait_time seconds of the stream is omitted). By default, this option is set to 0 (false).
- 'recover_any_error bool'
-
If set to 1 (true), recovery will be attempted regardless of type of the error causing the failure. By default this option is set to 0 (false) and in case of certain (usually permanent) errors the recovery is not attempted even when attempt_recovery is set to 1.
- 'restart_with_keyframe bool'
-
Specify whether to wait for the keyframe after recovering from queue overflow or failure. This option is set to 0 (false) by default.
Command line examples
- Stream something to rtmp server, continue processing the stream at real-time rate even in case of temporary failure (network outage) and attempt to recover streaming every second indefinitely.
ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format flv -map 0:v -map 0:a -drop_pkts_on_overflow 1 -attempt_recovery 1 -recovery_wait_time 1 rtmp://example.com/live/stream_name