-stream_loop
optionffmpeg -stream_loop 3 -i input.mp4 -c copy output.mp4
0
means no loop, -1
means infinite loop.The concat demuxer allows you to loop an input without needing to re-encode because it can use stream copy.
Make a text file. Contents of an example text file to repeat 4 times.
file 'input.mp4'
file 'input.mp4'
file 'input.mp4'
file 'input.mp4'
Then run ffmpeg
:
ffmpeg -f concat -i list.txt -c copy output.mp4
If you want to add additional inputs make sure they all have the same attributes.
list.txt
in Linux/macOSThis example is the same as above but you don't have to manually make list.txt
:
for i in {1..4}; do printf "file '%s'\n" input.mp4 >> list.txt; done
ffmpeg -f concat -i list.txt -c copy output.mp4
With most commonly-used modern shells, you can even avoid the creation of the list.txt
file entirely. For example, with bash:
ffmpeg -f concat -i <(for i in {1..4}; do printf "file '%s'\n" input.mp4; done) -c copy output.mp4