0

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?

1 Answers1

0

You should remove \ before , in python string, so it looks like:

.filter("select", "not(mod(n,30))")

Exctues
  • 1
  • 1
  • Answer needs supporting information Your answer could be improved with additional supporting information. Please [edit](https://stackoverflow.com/posts/76218357/edit) to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](https://stackoverflow.com/help/how-to-answer). – moken May 12 '23 at 11:23