> concatenation

Joining clips end-to-end, muxing separate audio and video tracks together, and looping footage. The right approach depends on whether your sources already share the same codec and parameters: matching streams can be concatenated losslessly with stream copy, while mismatched sources force a re-encode through the concat filter.

// concatenation

4 commands

// faq

Should I use the concat demuxer or the concat filter?

Use the concat demuxer (-f concat -c copy) when all clips share the same codec, resolution, and timebase — it copies streams without re-encoding, so it's fast and lossless. Use the concat filter (-filter_complex ...concat=...) when sources differ, since it re-encodes and can bridge mismatched inputs (after you normalize resolution/pixel format).

How do I add or replace the audio track of a video?

Feed both files as inputs and stream-copy the video while encoding the audio: ffmpeg -i input.mp4 -i audio.mp3 -c:v copy -c:a aac -shortest output.mp4. Add -map 0:v:0 -map 1:a:0 to be explicit about which streams to keep, since the original audio in input.mp4 would otherwise compete for selection.

Why is my concatenated video glitchy or out of sync?

The concat demuxer with -c copy assumes every input has identical codec, resolution, timebase, and SAR — any mismatch produces stutters, frozen frames, or A/V drift. When clips come from different sources, re-encode through the concat filter (normalizing resolution and pixel format first) instead of copying.