How to Use ffmpeg -re with Multiple Input Files
This article explains how to use the -re (read at native
frame rate) option in FFmpeg when working with multiple input files. You
will learn how FFmpeg interprets this flag, how to correctly position it
in your command line for multiple sources, and see practical examples
for live streaming and file concatenation.
Understanding the -re Option in FFmpeg
The -re option tells FFmpeg to read the input at its
native frame rate, simulating a live broadcast. By default, FFmpeg reads
files as fast as possible to complete processing quickly. The
-re option is essential when you are streaming a file to a
live destination (like RTMP or SRT) to prevent the stream from buffering
or flooding the ingest server.
Position Matters: How FFmpeg Applies -re
In FFmpeg, command-line options are position-sensitive. An input
option like -re applies only to the input file that
immediately follows it.
If you have multiple input files, you must specify the
-re option before each individual input file that you want
to read in real-time.
Scenario 1: Applying -re to All Inputs
If you are mixing or overlaying multiple video files and want both to
be processed in real-time, place -re before both
-i flags:
ffmpeg -re -i input1.mp4 -re -i input2.mp4 -filter_complex "[0:v][1:v]overlay=10:10[out]" -map "[out]" -f flv rtmp://live.twitch.tv/app/stream_keyScenario 2: Applying -re to Only One Input
If you have a primary video file that must stream in real-time, but
you are also importing a static image (like a watermark) or a loop that
does not require real-time throttling, only place -re
before the video file:
ffmpeg -re -i main_video.mp4 -i watermark.png -filter_complex "[0:v][1:v]overlay=main_w-overlay_w-10:10" -f flv rtmp://live.twitch.tv/app/stream_keyIn this command, main_video.mp4 is read in real-time,
while watermark.png is loaded normally without rate
limiting.
Scenario 3: Using -re with the Concat Demuxer
If you are streaming a list of multiple files sequentially using the
concat demuxer, you only need to apply the -re
flag once before the text file input.
Create a
playlist.txtfile:file 'video1.mp4' file 'video2.mp4'Run the FFmpeg command applying
-reto the list input:ffmpeg -re -f concat -safe 0 -i playlist.txt -c:v libx264 -c:a aac -f flv rtmp://live.twitch.tv/app/stream_key
This ensures the entire sequential playlist is read and streamed at native real-time speed.