I try to extract specific frame and crop frame by one command using ffmpeg.
I use those answers:
https://video.stackexchange.com/questions/4563/how-can-i-crop-a-video-with-ffmpeg
https://superuser.com/questions/1009969/how-to-extract-a-frame-out-of-a-video-using-ffmpeg
The problem is that I can't use both commands. That is, only the first command is executed:
when I use this command the crop doesn't work:
from moviepy.config import get_setting
cmd = [get_setting("FFMPEG_BINARY"), "-i", url, "-filter:v", f"crop={x2-x1}:{y2-y1}:{x1}:{y1}", "-vf", "select=gte(n\,10)", "-vframes", "1",frame_dir_out]
When I use this command it crop only the first frame and not the frame number 10:
cmd = [get_setting("FFMPEG_BINARY"), "-i", url, "-vf", "select=gte(n\,10)", "-vframes", "1", "-filter:v", f"crop={x2-x1}:{y2-y1}:{x1}:{y1}" ,frame_dir_out]
How can I combine 2 filter:v/vf options into a single filter chain?
CodePudding user response:
-filter
and -vf
are equivalent options. In both examples, simple Filtergraphs (one input -> one output) in ffmpeg are used. They can be combined by concatenating the filter expressions separated by a comma:
cmd = [get_setting("FFMPEG_BINARY"), "-i", url, "-filter:v", f"crop={x2-x1}:{y2-y1}:{x1}:{y1},select=gte(n\,10)", "-vframes", "1",frame_dir_out]
Best regards, Marc