Search code examples
ffmpegpyffmpeg

How can I crop multiple areas in each frame of the video using ffmpeg?


For each frame I want to crop multiple areas using ffmpeg but I am not sure how to proceed.

This is what I have done to crop one part of the image,

fmpeg -i video.mp4 -filter:v "fps=1,crop=759:41:33:99,scale=128:44" %d.png

This is one frame of the video,

enter image description here

The above command crops the number one row or first position from the image. Likewise I want to crop all the positions or rows from this frame. I tried passing multiple crop statements but that doesn't seem to work. What else I can try?


Solution

  • Make a crop per output. Example for rows 1 to 3:

    ffmpeg -i video.mp4 -vf "fps=1,crop=759:41:33:99,scale=128:-1" 1_%03d.png -vf "fps=1,crop=759:41:33:155,scale=128:-1" 2_%03d.png -vf "fps=1,crop=759:41:33:209,scale=128:-1" 3_%03d.png
    

    ...and so on.