Wednesday, September 19, 2018

looping videos and images on python using ffmpeg

#these program uses -stream_loop option
import os
#loop four times
os.system("ffmpeg -stream_loop 4 -i output.avi -c copy outputqsa.mp4")


#another option
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

#for images and gifs
-loop 
The -loop option is specific to the image file and gif .
This example will loop over and over but the -t 30 will limit the output duration to 30 seconds:
ffmpeg -loop 1 -i %03d.png -t 30 output.mkv

No comments:

Post a Comment