ffmpeg -f concat -i list.txt -c copy joins matching clips without re-encoding: three 4-second parts became one 12-second file in a fraction of a second. ReelSDK's free video merger does it in your browser, the API for $0.02 per compute minute.
Concatenate videos with ffmpeg: demuxer or filter
Use the demuxer when all clips share codec, size and frame rate, and the filter when a 1080x1920 clip meets a 1920x1080 one; ReelSDK's API runs either as one job. The filter re-encodes, so it took 34 seconds where the copy took a fraction of one.
GuidesUpdated
for f in part*.mp4; do echo "file '$f'"; done > list.txt
ffmpeg -f concat -i list.txt -c copy joined.mp4Write one file line per clip, in order, then let the concat demuxer copy the packets. Three 4-second parts, 1080x1920 H.264 at 30 fps with AAC audio, become one 12-second joined.mp4 in a fraction of a second.
Variations
The other commands you will need
Check that the clips match first
A copy join only works when every file has the same streams. Print the video stream of each clip and compare the lines; all three of ours printed
h264,1080,1920,yuv420p,30/1.compare clips for f in part*.mp4; do ffprobe -v error -select_streams v:0 \ -show_entries stream=codec_name,width,height,r_frame_rate,pix_fmt \ -of csv=p=0 "$f" doneJoin clips that differ with the concat filter
A vertical clip and a landscape clip can't share one copied stream. The filter fits the landscape clip into 1080x1920 with
scaleandpad, then joins video and audio. Seta=1: the filter's audio count defaults to 0.mixed.mp4came out at the two clips' combined length after a 34-second re-encode.filter join ffmpeg -i vertical.mp4 -i landscape.mp4 -filter_complex \ "[1:v]scale=1080:1920:force_original_aspect_ratio=decrease,\ pad=1080:1920:(ow-iw)/2:(oh-ih)/2,setsar=1[b];[0:v]setsar=1[a];\ [a][0:a][b][1:a]concat=n=2:v=1:a=1[v][au]" \ -map "[v]" -map "[au]" -c:v libx264 -crf 20 -c:a aac \ -movflags +faststart mixed.mp4What -c copy does with clips that don't match
We put the same two clips in a list and copied them anyway. ffmpeg printed a
Non-monotonic DTSwarning and still wrote the file, but its frames switch from 1080x1920 to 1920x1080 where the second clip starts. No error, a broken file: check before you copy.mismatched copy printf "file 'vertical.mp4'\nfile 'landscape.mp4'\n" > mixed.txt ffmpeg -f concat -i mixed.txt -c copy broken.mp4
The flags
The flags in these commands
| Flag | What it does | Used here |
|---|---|---|
-f concat | Reads the input as a list of files and plays them one after another | Copy join |
file 'part1.mp4' | One line of the list: a relative name in single quotes | list.txt |
-safe 0 | Accepts any name in the list, absolute paths and URLs too; the default safe=1 refuses them | Not used |
-c copy | Copies packets without re-encoding, so every clip must match | Copy join |
concat=n=2:v=1:a=1 | The filter: n segments, each with v video and a audio streams; a defaults to 0 | Filter join |
force_original_aspect_ratio=decrease | Shrinks the clip to fit inside the target size without changing its shape | Filter join |
pad=1080:1920:(ow-iw)/2:(oh-ih)/2 | Centers the picture on a 1080x1920 canvas, black by default | Filter join |
setsar=1 | Marks pixels as square so both segments agree | Filter join |
Sources: ffmpeg formats: concat demuxer, ffmpeg filters: concat, scale, pad, checked November 2026.
Demuxer, filter or protocol
ffmpeg has three ways to join files. The concat demuxer reads a list and hands the packets on as one stream; with -c copy nothing is decoded, which is why our join took a fraction of a second. The concat filter decodes every input to frames and joins those, so the clips can differ, but the result has to be encoded again.
The concat: protocol is the odd one out: it reads files back to back "as if they were a unique resource". On our three MP4 parts it printed Found duplicated MOOV Atom. Skipped it and kept only the first part, because every MP4 carries its own index. Remuxed to MPEG-TS first, the same parts joined to the full 12 seconds.
Why a copy join needs matching clips
The demuxer docs are blunt: "All files must have the same streams (same codecs, same time base, etc.)." It shifts each file's timestamps so it starts where the previous one ended, then passes the packets on untouched. The decoder downstream sees one stream, so a change of size, frame rate, pixel format or codec settings lands in the middle of it.
That is what our mismatched test shows: no error, a warning about timestamps, and a file whose frame size changes where the second clip begins. Run the ffprobe loop first; if any line differs, use the filter or re-encode the odd clip to match the others before you copy.
When the concat filter is worth the re-encode
Phone footage, screen recordings and exports from different apps rarely match. The filter takes them as they are, as long as you bring every video segment to one size first: "other settings, such as resolution, must be converted explicitly by the user." Here, scale and pad put the landscape clip on a 1080x1920 canvas.
The price is time. The copy join finished in a fraction of a second; the filter join of two short clips took 34 seconds with libx264 at CRF 20 on 2 CPU cores. If you join clips on a server, the same args run through the API on a fresh machine per job.
Paths in the list
With the default safe=1, the demuxer accepts only plain relative names. An absolute path stopped our run with Unsafe file name and Operation not permitted. Locally, -safe 0 lifts the check; the API refuses -safe 0, so keep the list and the clips side by side and use bare file names, as list.txt does above.
Without installing ffmpeg
The same command as one API call
Send the list and the clips as inputs; they land in one job folder, so the names in list.txt resolve. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second. The join above finished in under 3 seconds and cost under a tenth of a cent.
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
-H "Authorization: Bearer $REELSDK_KEY" \
--json '{
"inputs": {
"list.txt": "https://api.reelsdk.com/f/lib/in/guides/concat-list.txt",
"part1.mp4": "https://api.reelsdk.com/f/lib/out/job_7oyb9n8bq1868dv7j2um/part1.mp4",
"part2.mp4": "https://api.reelsdk.com/f/lib/out/job_7oyb9n8bq1868dv7j2um/part2.mp4",
"part3.mp4": "https://api.reelsdk.com/f/lib/out/job_7oyb9n8bq1868dv7j2um/part3.mp4"
},
"args": ["-f", "concat", "-i", "list.txt", "-c", "copy", "joined.mp4"],
"outputs": ["joined.mp4"]
}'FAQ
Questions, answered
Can I join MP4 files without re-encoding?
Yes, when every file has the same codec, size, frame rate and audio format. Put them in a list and run ffmpeg -f concat -i list.txt -c copy joined.mp4. Three 4-second parts joined in a fraction of a second into one 12-second file.
How do I join videos with different resolutions?
Use the concat filter and bring each video to one size first, for example with scale and pad. ffmpeg won't do it for you: the filter needs the same parameters in all segments, apart from pixel and sample formats it picks itself.
Why does my concat filter output have no audio?
The filter's a option, the number of audio streams per segment, defaults to 0. Set concat=n=2:v=1:a=1, pass the audio pads in order after each video pad, and map the audio output with -map.
What does Unsafe file name mean in ffmpeg concat?
The list holds an absolute path, a protocol or unusual characters, and the demuxer's default safe=1 refuses those. Use relative names next to the list, or add -safe 0 before -i on your own machine.
Can I join videos without installing ffmpeg?
Yes. Send the list and the clips as inputs to POST https://api.reelsdk.com/v1/ffmpeg with the same args. It runs ffmpeg 8.1 on a fresh machine per job for $0.02 per compute minute, billed per second with a 1-second minimum, and failed jobs are free.
- Unir vídeos con FFmpegUne clips con el demuxer concat y -c copy cuando coinciden, o con el filtro concat cuando cambian el tamaño, la cadencia o el códec.
- ffmpeg xfade transitions, all 59 renderedEvery xfade transition in ffmpeg 8.1 as a clip you can play, with the offset math and the fix for the do-not-match error.
- ffmpeg -filter_complex explainedLabels, commas and semicolons: how a filtergraph wires inputs to outputs, with four working graphs and the errors they fix.
- Trim a video with ffmpegCut a clip with -ss and -to: frame-exact with a re-encode, fast with -c copy, and why the copy starts before your time.
- Resize a video with ffmpegScale a video with scale=w:h: keep the aspect ratio with -2, fit a 1080x1920 frame with pad, and fix the odd-size error.
- Letterbox and pad a video with ffmpegFit any video into a 9:16, 16:9 or square frame with black or coloured bars, then find and strip bars with cropdetect.
- Change the frame rate with ffmpegConvert a video to 24, 30 or 60 fps with the fps filter, see how -r differs, and make smooth 60 fps with minterpolate.
- Merge videosJoin videos into one in your browser, as they are or resized to match, free and without uploading them, or with one API call.
- Merge videosJoin clips into one MP4 by URL with the concat filter or demuxer, up to 50 inputs, for well under a cent a merge.
- Non-monotonous DTS in output streamPackets reach the muxer with timestamps that go backwards, often from joining unlike clips with -c copy. Re-encode with the concat filter.
- ReelSDK vs self-hosted FFmpegTranscoding a minute of 1080p to 720p takes about 24 seconds of compute: about 0.8 cents on ReelSDK, about a tenth of a cent on a busy 4 vCPU box. Below about 11,000 minutes a month, the API costs less than an always-on box.
Ready to build?
Ship video from your app today
Your first $0.50 is free, and one key covers every endpoint.
