Joining multiple video clips into one file is a daily task. When the clips share the same codec, resolution, frame rate, and time base, stream copy can concatenate them with no quality loss and in the time it takes to read the files.

The command

# filelist.txt
file 'part1.mp4'
file 'part2.mp4'

ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.mp4

What it does

FFmpeg's concat demuxer reads the file list, opens each input, and writes their packets in order to the output. The -safe 0 flag tells it to allow non-standard file names. Audio and video streams are interleaved according to their timestamps, which FFmpeg rebases so the output has a continuous timeline starting at 0.

When to use it

For stitching together multi-cam shots, joining segments from the same source, or assembling a deliverable from a known set of clips. The key requirement is that all inputs share the same codec parameters; if they do not, FFmpeg will error rather than guess.

Video and audio requirements

All inputs must have the same codec, resolution, frame rate, pixel format, audio codec, sample rate, and channel layout. Mismatched inputs are rejected. For mixed-format joining, use the filter-graph concat instead, which re-encodes.

Things to avoid

  • Mixing files with different codecs or resolutions. The concat demuxer does not re-encode and will refuse the job rather than silently producing a broken file.
  • Forgetting -safe 0 if your file names contain special characters. Without it, paths with colons or apostrophes are rejected for safety.
  • Concatenating files that span different time bases. The output may have stuttering at the join because the PTS rebasing is coarse. Re-encode for a clean result.
  • Using relative paths in the file list without running FFmpeg from the right directory. Absolute paths are safer.