I would like to crop out ROI from specific .mp4 file. User needs to define the ROI by specifying
Height in percentage between 0 and 10000.
For example, if someone specifies
Y=3000 that would mean that top left corner (starting point of the crop) is located 40% to the right from bottom left corner of the video, and 30% down from top left corner of the video.
Height should determine bottom right and top left corners.
I am currently doing some tests on this image:
I expected following command to crop out 50% of the width and 50% of the height of the image, starting from top left corner:
ffmpeg -i test.png -filter:v "crop=in_w*(5000/10000):in_h*(5000/10000):in_w:in_h" -c:a copy roi.png
For some reason I get bottom right quarter instead of top left quarter of the image. What am I doing wrong?
Once I change command to:
ffmpeg -i test.png -filter:v "crop=in_w*(5000/10000):in_h*(5000/10000):0:in_h" -c:a copy roi.png
I get top right quarter of the image:
Since I specified
Y=0, this means that
(X,Y) is top-right corner of the image. If that is true, and
W is 50% of
H is also 50% of
in_h, and I specified
(X,Y) to be at top right corner, how did FFMPEG decide that it needs to go to the LEFT of the
(X,Y) coordinate and not to the RIGHT in order to make the crop?
Because if it went to the right like it normally does, it would go out of range I guess. How is this logic implemented? I would like to know so I know how to program edge cases for it.