How to Merge and Concatenate Videos with FFmpeg (2026 Guide)
Complete guide to merging and concatenating multiple video files using FFmpeg. Covers concat demuxer, filter, protocol methods, and a free one-click alternative.

Have multiple video clips you need to join into one file? FFmpeg offers several ways to concatenate videos, but the right method depends on what is inside the files: video codec, resolution, timestamps, and whether every clip has audio.
This guide covers three approaches with commands you can adapt. If you’d rather work with a visual tool, there’s a free drag-and-drop alternative at the end.
Prerequisites: Install FFmpeg

macOS:
brew install ffmpeg
Ubuntu/Debian:
sudo apt update && sudo apt install ffmpeg
Windows: Download a Windows build through ffmpeg.org, extract it, and add its bin folder to PATH.
Check that both commands are available:
ffmpeg -version
ffprobe -version
Check Your Clips Before You Pick a Method
This quick check saves time later. Run it on each input file:
ffprobe -v error -show_entries stream=index,codec_type,codec_name,width,height,pix_fmt,r_frame_rate,time_base,sample_rate,channel_layout -of default=noprint_wrappers=1 clip1.mp4
Compare the video and audio streams. If the clips have the same stream layout and compatible codec parameters, try Method 1. Matching .mp4 extensions alone are not enough. If the codecs, resolution, or audio tracks differ, use Method 2 and normalize what needs to match. The FFmpeg concat documentation requires the demuxer’s inputs to have the same streams, including codecs and time bases.
No audio stream in one clip? The 0:a references in the audio examples below will fail until you add silence or use a video-only command. That is worth finding out before you paste a long filter.
Method 1: Concat Demuxer (Same Format — Fastest)
Use the concat demuxer when the clips have matching stream structure and encoding parameters. With -c copy, FFmpeg joins their compressed streams without re-encoding, so this is usually the quickest route. Matching codec and resolution are useful first checks; also compare audio streams and time bases.
Step 1: Create a file list
Create files.txt in the same folder as the clips:
file 'clip1.mp4'
file 'clip2.mp4'
file 'clip3.mp4'
The order in this file is the output order. If a filename contains spaces, keep the quotes. FFmpeg’s list-file syntax has its own escaping rules, so a filename containing an apostrophe needs extra care.
Step 2: Run the concat command
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4
-f concatreads the list with the concat demuxer.-safe 0permits paths that FFmpeg’s default safety check would reject, including absolute paths and names with spaces. Use it with a list you created and trust.-c copyskips re-encoding. The job still has to read and write the media; it is not literally instant.
Play the result across each join. A command finishing successfully does not guarantee clean playback if the source streams or their durations disagree.
Generate the file list automatically
Linux/macOS, for simple filenames without apostrophes:
: > files.txt
for f in ./*.mp4; do
[ -e "$f" ] || continue
[ "$f" = "./output.mp4" ] && continue
printf "file '%s'\n" "$f" >> files.txt
done
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4
Windows PowerShell, for ASCII filenames including spaces and apostrophes:
Get-ChildItem -File -Filter *.mp4 |
Where-Object Name -ne 'output.mp4' |
Sort-Object Name |
ForEach-Object { "file '$($_.Name.Replace("'", "'\''"))'" } |
Set-Content -Encoding ascii files.txt
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4
Both examples exclude an existing output.mp4 so a second run does not add yesterday’s result to today’s list. Check files.txt before running; automatic filename order may not be the story order you want.
Method 2: Concat Filter (Different Formats — Most Flexible)

Use the concat filter when you need to decode and re-encode clips. Different input codecs are fine. Different resolutions still need explicit scaling, and every segment must supply the same number of video and audio streams to the filter. The examples immediately below assume each clip has one video stream, one audio stream, and the same resolution.
Two videos
ffmpeg -i clip1.mp4 -i clip2.mov \
-filter_complex "[0:v:0]setpts=PTS-STARTPTS[v0];[0:a:0]asetpts=PTS-STARTPTS[a0];[1:v:0]setpts=PTS-STARTPTS[v1];[1:a:0]asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1[outv][outa]" \
-map "[outv]" -map "[outa]" -c:v libx264 -crf 20 -c:a aac output.mp4
Resetting each stream’s timestamps matters because the concat filter expects every segment to start at zero.
Three videos
ffmpeg -i clip1.mp4 -i clip2.mov -i clip3.avi \
-filter_complex "[0:v]setpts=PTS-STARTPTS[v0];[0:a]asetpts=PTS-STARTPTS[a0];[1:v]setpts=PTS-STARTPTS[v1];[1:a]asetpts=PTS-STARTPTS[a1];[2:v]setpts=PTS-STARTPTS[v2];[2:a]asetpts=PTS-STARTPTS[a2];[v0][a0][v1][a1][v2][a2]concat=n=3:v=1:a=1[outv][outa]" \
-map "[outv]" -map "[outa]" -c:v libx264 -crf 20 -c:a aac output.mp4
Here, n=3 is the number of clips, v=1 produces one video stream, and a=1 produces one audio stream. Change the inputs and n together.
Normalize resolution before concatenating
If two clips have different sizes, scale and pad them to a common 1920×1080 frame before the concat filter:
ffmpeg -i clip1.mp4 -i clip2.mp4 \
-filter_complex "[0:v]setpts=PTS-STARTPTS,scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v0];[1:v]setpts=PTS-STARTPTS,scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v1];[0:a]asetpts=PTS-STARTPTS[a0];[1:a]asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1[outv][outa]" \
-map "[outv]" -map "[outa]" -c:v libx264 -crf 20 -pix_fmt yuv420p -c:a aac output.mp4
The padding preserves each clip’s aspect ratio. Replace 1920:1080 in both branches if you need another output size.
Method 3: Concat Protocol (Compatible MPEG-TS Streams)
The concat protocol reads files as one physical byte stream. The example below is for compatible H.264 video and AAC audio converted to MPEG-TS. It is not a general way to join arbitrary .mp4, .mov, or .ts files.
# First convert compatible H.264/AAC clips to MPEG-TS
ffmpeg -i clip1.mp4 -c copy -bsf:v h264_mp4toannexb clip1.ts
ffmpeg -i clip2.mp4 -c copy -bsf:v h264_mp4toannexb clip2.ts
# Then concatenate and write MP4
ffmpeg -i "concat:clip1.ts|clip2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
Check codecs with ffprobe first. If the clips do not meet those assumptions, use Method 1 or 2. For most ordinary clip lists, the concat demuxer is easier to manage. FFmpeg documents the protocol as physical concatenation, which is why file compatibility matters so much here.
Special Scenarios
Merge Video and Audio Tracks
Combine a video with a separate audio file:
ffmpeg -i video.mp4 -i audio.mp3 -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac -shortest output.mp4
-shortest stops when the shorter output stream ends. Remove it if that is not the ending you want.
Replace Audio in a Video
ffmpeg -i video.mp4 -i new_audio.mp3 -map 0:v:0 -map 1:a:0 -c:v copy -c:a aac output.mp4
The -map options select the original picture and the new audio, leaving the original audio out.
Concatenate Videos with Different Frame Rates
The concat filter can accept different frame rates, but the result may be variable frame rate. If you need a constant 30 fps output, apply fps=30 to both video inputs:
ffmpeg -i clip1.mp4 -i clip2.mp4 \
-filter_complex "[0:v]fps=30,setpts=PTS-STARTPTS[v0];[1:v]fps=30,setpts=PTS-STARTPTS[v1];[0:a]asetpts=PTS-STARTPTS[a0];[1:a]asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1[outv][outa]" \
-map "[outv]" -map "[outa]" -c:v libx264 -crf 20 -c:a aac output.mp4
This still assumes matching resolution and an audio stream in each input. The fps filter may duplicate or drop frames to reach 30 fps.
Videos Without Audio
If you need to join a silent clip to clips that have audio, first give the silent clip an audio stream:
ffmpeg -i clip_no_audio.mp4 -f lavfi -i anullsrc=r=48000:cl=stereo \
-map 0:v:0 -map 1:a:0 -c:v copy -c:a aac -shortest clip_with_silence.mp4
anullsrc supplies silence; -shortest ends it with the video. Then use the concat filter with the other clips, or use the demuxer only if the resulting streams also match its requirements. If every clip is silent, use concat=n=2:v=1:a=0 with video inputs alone instead.
Common Errors and Fixes
“Non-monotonous DTS” or bad timing at a join
This points to timestamp trouble, but one flag will not repair every source. First find which clip or join fails. If a clip has video and audio, re-encode that clip with timestamps starting at zero, then try the join again:
ffmpeg -i bad_clip.mp4 -vf "setpts=PTS-STARTPTS" -af "asetpts=PTS-STARTPTS" \
-c:v libx264 -c:a aac fixed_clip.mp4
Use the video-only form if the clip has no audio. Re-check codec, resolution, and stream layout before feeding the repaired file to Method 1.
“Stream 0 codec does not match”
Check the inputs with ffprobe. The demuxer needs compatible streams, not merely matching file extensions. If they differ, use Method 2 and normalize resolution or missing audio as needed.
“Discarding 1 additional packets” or audio out of sync
A warning alone does not prove the output is broken. Play across the joins and compare input durations. The demuxer uses each file’s duration to position the next one, so an incorrect duration can create gaps or overlap. If the output is actually out of sync, use the filter path with timestamps reset, and inspect the problem clip rather than assuming -fflags +genpts will fix it.
Black frames between clips
Check the source clips and the exact join first; a black frame is not proof of a pixel-format mismatch. If the inputs use different formats, normalize them while re-encoding:
ffmpeg -i clip1.mp4 -i clip2.mp4 \
-filter_complex "[0:v]setpts=PTS-STARTPTS,format=yuv420p[v0];[1:v]setpts=PTS-STARTPTS,format=yuv420p[v1];[0:a]asetpts=PTS-STARTPTS[a0];[1:a]asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1[outv][outa]" \
-map "[outv]" -map "[outa]" -c:v libx264 -c:a aac output.mp4
This example still requires equal resolution and audio in both clips.
Skip the Terminal: Use WaveSpeed Desktop Instead
Merging videos with FFmpeg means choosing a method, checking streams, and sometimes fixing a filter graph. If you’d rather arrange clips visually, WaveSpeed Desktop includes a Media Merger:
- Add your video clips.
- Put them in the order you want.
- Merge and preview the result, especially at the joins.

WaveSpeed lists Media Merger among its free tools. I would still check the output settings and preview when the source files have different formats or resolutions; “automatic” does not tell you which codec, size, or frame rate the final file will use.
Download WaveSpeed Desktop for free: official releases
FAQ
Which contact method should I use?
Use the demuxer with -c copy when stream structure and encoding parameters match. Use the filter when you need to re-encode, scale, or supply missing audio. Reserve the protocol example for compatible transport streams.
Can I add transitions between clips?
Yes. FFmpeg has an xfade filter, but the commands above make hard cuts. A visual editor may be easier if you need to adjust transitions by eye.
Does merging videos reduce quality?
-c copy does not re-encode the video, so it avoids generation loss. The filter examples re-encode; quality depends on the output settings. The examples use CRF 20, and you can try 18–20 if you need a larger, higher-quality H.264 file.
Is there a limit to how many videos I can merge?
There is no small fixed clip limit in these examples. Long lists still take time and storage; the filter method also becomes cumbersome when every clip is a separate input.
Previous posts:
/filters:quality(82)/media/images/1773962750383987480_n3hqzHRZ.webp)
/filters:quality(82)/media/images/0398e05e-3518-4fa9-9639-00018feb645e.webp)
/filters:quality(82)/media/images/1775454354154780718_ODFPZcmw.webp)
/filters:quality(82)/media/images/1775454354187499843_FsWsCKow.webp)
/filters:quality(82)/media/images/1775454352321281840_iOvFOX6f.webp)
/filters:quality(82)/media/images/1774495742042616105_ZIR0ajsB.webp)