[FFmpeg-user] crop filter, how to move crop rectangle along the y-axis ?

Moritz Barsnick barsnick at gmx.net
Mon Jun 26 12:15:01 EEST 2017


On Sat, Jun 24, 2017 at 18:56:23 +0200, Sub Phil wrote:
> *Along x-axis, this works, crop rectangle jumps from x=200 to x=400 when t>4*
> ffmpeg -y -i "30secGraduated1280x720.mp4" -vf
> "crop=in_w-780:in_h-200:if(lt(t\,4)\,200\,400):0" -c:v libx264 -preset:v
> ultrafast -crf 27 -an _outALPHA.mp4
> 
> *Along y-axis, crop rectangle stay fixed.*
> F:\dbtest>ffmpeg -y -i "30secGraduated1280x720.mp4" -vf
> "crop=in_w-780:in_h-200:0:if(lt(t\,4)\,200\,400)" -c:v libx264 -preset:v
> ultrafast -crf 27 -an _outALPHA.mp4

> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '30secGraduated1280x720.mp4':
>   Duration: 00:00:30.00, start: 0.000000, bitrate: 16 kb/s
>     Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1280x720 [SAR 1:1 DAR 16:9], 13 kb/s, 25 fps, 25 tbr,

w: 1280(in_w) - 780  = 500 width out(out_w)
h: 720(in_h   - 200  = 520 height out(out_h)
y: 200 + 520(out_h)  = 720 -> can be cropped out of input height
y: 400 + 520(out_h)  = 920 -> outside of field, cannot be cropped.

Unfortunately, the filters apparently don't give a warning when one of
the eval expressions goes out of bounds, but instead ignore it. And I
haven't found a verbosity level where the eval of the filter shows its
effective values.

If works if you pad the frame:
  "pad=w_in_w:h=in_h+200,crop=in_w-780:in_h-200-200:0:if(lt(t\,4)\,200\,400)"

Regards,
Moritz


More information about the ffmpeg-user mailing list