FFmpeg recipe
FFmpeg: Merge / Concatenate Two MP4 Videos
For videos with identical codec / resolution / fps, concat demuxer is lossless and instant. Otherwise use the concat filter to re-encode.
Command
# Step 1: build a list file
echo "file 'clip1.mp4'
file 'clip2.mp4'" > list.txt
# Step 2: concat (lossless)
ffmpeg -f concat -safe 0 -i list.txt -c copy -y output.mp4Prefer no terminal?
Use the Video Merger in your browser
What each flag does
| -i | Input file. Can be a video, audio, or image. Repeat for multiple inputs. |
|---|---|
| -c copy | Stream-copy: no re-encoding. Output is bit-identical between cut points. Fastest possible. |
| -y | Overwrite output file without confirmation. |
| -f concat | Use the concat demuxer (file-list-driven concatenation). |
| -safe 0 | Allow absolute paths in the list file. |
Notes & gotchas
- All inputs must share codec, resolution, frame rate, and audio settings for -c copy. Mismatch → garbled output.
- For mismatched inputs, use the concat filter: -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[v][a]" with re-encoding.
Related recipes
Extract a single frame · Any video
Extract one frame from a video at a specific timestamp using FFmpeg. Useful for thumbnails and previews.
Trim · MP4
Trim an MP4 with FFmpeg using stream-copy for lossless, instant output. Copy-paste command with explanations.
Trim (frame-accurate) · MP4
Frame-accurate MP4 trim with FFmpeg. Re-encodes for exact-frame precision — use when -c copy keyframe snapping is not OK.
Convert MOV → MP4 · MOV → MP4
Convert MOV to MP4 with FFmpeg using H.264 video and AAC audio. CRF 23 default keeps quality visually identical.