Loop a short clip to a target duration
If you have a 30-second bumper and need a 5-minute placeholder, the `stream_loop` flag tells the demuxer to loop the input a fixed number of times. Combined with `-t` to limit the output duration, you get a precise-length file that uses only the source material.
The command
ffmpeg -stream_loop -1 -i short.mp4 -t 300 -c copy looped.mp4What it does
`-stream_loop -1` loops the input indefinitely; `-t 300` stops the output after 300 seconds. The result is a 5-minute file made by concatenating the 30-second source 10 times. The command uses `-c copy`, so no re-encoding happens — it runs at I/O speed. The output plays in any player that supports the container, with the source material repeated end to end.
Requirements
Any container FFmpeg can both read and write. Stream copy is sufficient, so no encoder is loaded. The loop count and the target duration must be consistent: a 30-second source looped 10 times is exactly 300 seconds.
Things to avoid
- Looping a clip with audio that has a hard out at the end. The cut will be audible at the loop boundary; crossfade the audio with `acrossfade` for a smoother loop.
- Looping a clip with a different framerate than the target. The output will have the source framerate, which may not match the project's expected framerate.
- Using `-stream_loop -1` without `-t`. The output will run forever; the command will not exit on its own.
- Expecting the loop to be seamless. The demuxer concatenates the source end to end, so any silence or hard cut at the end of the source will be audible.