I don't have much experience with ffmpeg and the somewhat not-so-beginner-friendly ffmpeg-python package's documentation has left me kind of confused.
I'm trying to trim a video from second s
to second e
and then grab one frame for every second (the video is 30fps). Then save all these frames (around e-s
many frames) in a video file.
So far what I have is this:
(
in_file
.trim(start=s, end=e)
.filter("select", "not(mod(n\,30))")
.setpts("PTS-STARTPTS")
.output("test.mp4", loglevel="quiet")
.overwrite_output()
.run()
)
without using filter
the script runs but I'm still not getting one frame per second. So I looked into the select filter and I believe you give it the expression not(mod(n\,30))
to make it falsify for all frames that are not a modulo of 30, and then it keeps going up one by one to stack the frames one after another.
this however gives me an error:
Traceback (most recent call last):
File "/home/***/Videos/test.py", line 26, in <module>
.run()
File "/home/***/.local/lib/python3.10/site-packages/ffmpeg/_run.py", line 325, in run
raise Error('ffmpeg', out, err)
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)
Any thoughts?