10/20/2025

Merge MP4 videos with FFmpeg using fast lossless concat or compatible re-encoding. Includes files.txt, no-audio commands, checks, and common fixes.

How to Merge MP4 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.

Quick Answer

Use the concat demuxer with -c copy when your MP4 clips have matching stream properties:

ffmpeg -f concat -safe 0 -i list.txt -c copy merged.mp4

If the clips have different codecs, dimensions, frame rates, or audio layouts, normalize or re-encode them before merging.

Situation Best method Re-encoding
Clips from the same camera or export Concat demuxer with -c copy No
Different formats or stream settings Concat filter Yes
Video-only clips Concat filter with a=0 Yes

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.

Check Whether Clips Match

Before using stream copy, inspect each clip with ffprobe:

ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,width,height,r_frame_rate,time_base -of default=noprint_wrappers=1 clip1.mp4

Run the same command for every input. Codec, width, height, frame rate, and time base should match. Also check that every clip either has compatible audio or consistently has no audio.

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

Related tool

Merge Videos with FFmpeg

Create FFmpeg concat commands to merge MP4 and other video files, with fast stream-copy and compatible re-encode modes.

Open the command generator