Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split video into images with ffmpeg-python

As far as I understand ffmpeg-python is main package in Python to operate ffmpeg directly.

Now I want to take a video and save it's frames as separate files at some fps.

There are plenty of command line ways to do it, e.g. ffmpeg -i video.mp4 -vf fps=1 img/output%06d.png described here

But I want to do it in Python. Also there are solutions [1] [2] that use Python's subprocess to call ffmpeg CLI, but it looks dirty for me.

Is there any way to to make it using ffmpeg-python?

like image 773
sgt pepper Avatar asked Jan 20 '26 00:01

sgt pepper


1 Answers

The following works for me:

ffmpeg
.input(url)
.filter('fps', fps='1/60')
.output('thumbs/test-%d.jpg', 
        start_number=0)
.overwrite_output()
.run(quiet=True)
like image 151
norus Avatar answered Jan 21 '26 15:01

norus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!