Use the concat demuxer with a list file
When the concatenation order is fixed and the input files all share the same codec and parameters, the `concat` demuxer is the fastest way to join them. It runs at I/O speed, requires no re-encoding, and is driven by a plain-text list file.
The command
ffmpeg -f concat -safe 0 -i list.txt -c copy out.mp4What it does
The command reads `list.txt`, which is a text file with one line per input: `file 'a.mp4'`, `file 'b.mp4'`, `file 'c.mp4'`. The `concat` demuxer opens each file in order, demuxes the streams, and writes them to the output. The output is the exact concatenation of the inputs, container and all. The command uses stream copy, so no re-encoding happens — it runs at I/O speed.
Requirements
Input files that all share the same codec, resolution, frame rate, and sample rate. The `concat` demuxer does not transcode; mismatched files will produce a malformed output. The list file must use single-quoted filenames, and the `safe 0` flag allows paths outside the current directory.
Things to avoid
- Mixing codecs in the input list. The demuxer will demux each file, but the muxer will fail or produce a malformed file. Use the `concat` filter for mismatched inputs.
- Forgetting the `safe 0` flag. Without it, the demuxer refuses paths outside the current directory.
- Using a list file with absolute paths on Windows. The list file uses single-quoted paths, but Windows path separators may confuse the demuxer. Use forward slashes or relative paths.
- Expecting the demuxer to re-sync audio. If the inputs have different audio timestamps, the output will have a gap or overlap. Use the `aresample` filter to normalize the audio.