10/20/2025
Merge MP4 and other video files with FFmpeg. Learn the fast lossless concat method, the re-encoding filter method, and how to fix common merge errors.
How to Merge Videos with FFmpeg
FFmpeg can merge videos in two main ways. The right method depends on whether your clips have matching codecs, resolution, frame rate, and audio layout.
For a guided command builder, use the FFmpeg merge videos tool. For a copyable command, choose one of the methods below.
Method 1: Fast Lossless Merge
Use this when the clips came from the same camera, phone, screen recorder, or export settings.
Create a file named list.txt:
file 'clip1.mp4'
file 'clip2.mp4'
file 'clip3.mp4'
Then run:
ffmpeg -f concat -safe 0 -i list.txt -c copy merged.mp4
This is the fastest and cleanest method because -c copy avoids re-encoding. Quality stays the same and the command usually finishes quickly.
What the Options Mean
| Option | Meaning |
|---|---|
-f concat |
Tells FFmpeg to read a concat list file. |
-safe 0 |
Allows normal relative or absolute paths in the list file. |
-i list.txt |
Uses the list of clips as the input. |
-c copy |
Copies streams without re-encoding. |
merged.mp4 |
The final joined video. |
Method 2: Merge Different Videos
If your clips have different formats, resolutions, or codecs, use the concat filter. This re-encodes the final video so the streams become compatible.
ffmpeg -i clip1.mp4 -i clip2.mov -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v libx264 -c:a aac merged.mp4
Use this when:
- One clip is MP4 and another is MOV, AVI, or WebM.
- The clips have different dimensions or frame rates.
- The fast concat command fails or creates broken output.
Merge Videos Without Audio
If your clips do not have audio, or you want to remove audio from the final file:
ffmpeg -i clip1.mp4 -i clip2.mp4 -filter_complex "[0:v:0][1:v:0]concat=n=2:v=1:a=0[v]" -map "[v]" -c:v libx264 merged.mp4
The important part is a=0, which tells the concat filter not to expect audio streams.
Create the List File Safely
The concat demuxer reads clips in the order listed in list.txt. On macOS or Linux, you can generate a simple list for MP4 files:
printf "file '%s'\n" *.mp4 > list.txt
Check the file before running FFmpeg. Alphabetical order may not be the order you want, especially for files named 1.mp4, 2.mp4, and 10.mp4.
Common Merge Errors
Unsafe file name
Add -safe 0, or use simple relative paths in list.txt.
The output has no audio.
One or more inputs may not contain audio. Use the no-audio command, normalize the clips first, or use the error explainer with the exact message.
The fast merge creates a broken file.
Your clips probably do not have matching stream properties. Use the concat filter method instead.
The concat filter command fails.
Check whether every input has both video and audio. If not, use the no-audio version or add silent audio before merging.
Related FFmpeg Pages
- Build a custom command with the Merge Videos tool.
- See the short recipe: Merge MP4 files with FFmpeg.
- Learn how to convert video formats with FFmpeg before merging mismatched files.
Related tool
Merge Videos with FFmpeg
Create FFmpeg concat commands for joining video files, with copy and re-encode options.
Open the command generator