Join videos with different codecs using re-encoding

concatenation

// what it does

Uses the concat filter (not the demuxer) to join two inputs, feeding their video and audio streams in interleaved order [0:v:0][0:a:0][1:v:0][1:a:0] with n=2 segments, v=1 video and a=1 audio stream each, then mapping the labeled [outv]/[outa] outputs. Unlike stream copy, the filter decodes and re-encodes everything, so it can bridge clips that were encoded with different codecs. This is the go-to when the concat demuxer refuses your files because their codecs don't match.

// shell

$ ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4

// gotcha

The concat filter still requires every segment to share the same resolution, pixel format, and SAR — differing sizes must be scaled/padded (scale, setsar) beforehand or the filter errors out. Re-encoding also costs CPU time and a generation of quality loss, so don't use it when the demuxer's -c copy would work.