Loop a video N times

concatenation

// what it does

-stream_loop is an input option (it must appear before -i) that repeats the input stream; since a value of 0 means no loop, a value of 3 means three additional loops, so the source plays four times total. With -c copy the packets are stream-copied, so the loop is lossless and fast. Use -stream_loop -1 for an infinite loop, typically paired with an output duration limit like -t.

// shell

$ ffmpeg -stream_loop 3 -i input.mp4 -c copy output.mp4

// gotcha

-stream_loop 3 produces four playthroughs, not three — the count is extra repeats on top of the original. Because -c copy carries over the original timestamps, loop boundaries can introduce DTS/PTS discontinuities (non-monotonic DTS warnings) that make some players stutter or misreport duration; re-encode if you need a seamless loop.