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

copy join
for f in part*.mp4; do echo "file '$f'"; done > list.txt
ffmpeg -f concat -i list.txt -c copy joined.mp4

Write 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

  1. 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"
    done
  2. Join 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 scale and pad, then joins video and audio. Set a=1: the filter's audio count defaults to 0. mixed.mp4 came 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.mp4
  3. What -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 DTS warning 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

The flags in these commands
FlagWhat it doesUsed here
-f concatReads the input as a list of files and plays them one after anotherCopy join
file 'part1.mp4'One line of the list: a relative name in single quoteslist.txt
-safe 0Accepts any name in the list, absolute paths and URLs too; the default safe=1 refuses themNot used
-c copyCopies packets without re-encoding, so every clip must matchCopy join
concat=n=2:v=1:a=1The filter: n segments, each with v video and a audio streams; a defaults to 0Filter join
force_original_aspect_ratio=decreaseShrinks the clip to fit inside the target size without changing its shapeFilter join
pad=1080:1920:(ow-iw)/2:(oh-ih)/2Centers the picture on a 1080x1920 canvas, black by defaultFilter join
setsar=1Marks pixels as square so both segments agreeFilter 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.

terminalTry it
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"]
  }'
joined.mp4 from the API: 12 seconds, byte-identical to the local join.Input: list.txtpart1.mp4part2.mp4part3.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.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains