C.W.K.
Stream
Lesson 08 of 10 · published

Concatenation — Joining Clips

~12 min · concat, join, merge

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

Three concat methods, three different tradeoffs

Joining clips in FFmpeg has three documented methods. They are not interchangeable.

  1. concat demuxer (file-list) — fastest. Requires identical codecs/parameters across all inputs. Stream-copy compatible.
  2. concat protocol (concat:) — works only with MPEG-TS or other 'cat-able' streams. Use for joining segments from -f segment.
  3. concat filter — slowest, most flexible. Re-encodes everything. Handles different resolutions/codecs/frame rates by normalizing them in a filtergraph.

The 80% case: concat demuxer

If your clips came from the same camera/encoder, the concat demuxer is the right tool. Make a text file listing the inputs, point FFmpeg at it.

Code

concat demuxer (fastest)·bash
# 1) Build a list file
cat > files.txt <<'EOF'
file 'clip1.mp4'
file 'clip2.mp4'
file 'clip3.mp4'
EOF

# 2) Concat without re-encoding (requires matching codecs/params)
ffmpeg -f concat -safe 0 -i files.txt -c copy joined.mp4

# Common pitfall: 'safe 0' is required if your paths contain absolute paths
# or special characters. Without it FFmpeg refuses for security reasons.
concat filter (heterogeneous inputs)·bash
# Different resolutions/codecs — must re-encode and normalize
ffmpeg -i clip1.mov -i clip2.webm -i clip3.mkv \
  -filter_complex "[0:v]scale=1920:1080,fps=30[v0]; \
                   [1:v]scale=1920:1080,fps=30[v1]; \
                   [2:v]scale=1920:1080,fps=30[v2]; \
                   [v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[outv][outa]" \
  -map "[outv]" -map "[outa]" \
  -c:v libx264 -crf 20 -preset slow \
  -c:a aac -b:a 192k \
  joined.mp4

External links

Exercise

Take a 30-second clip and slice it into three 10-second chunks (Track 2 lesson 7). Then re-join them with the concat demuxer, copy mode. Verify total duration matches the original within ±0.1s. Then deliberately downscale one chunk to 720p and try concat again — does it succeed? What happens?

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.