I'm trying to crop video frames with ffmpeg, and I would like to scale the cropped image automatically. I saw an option at av filter: http://ffmpeg.org/libavfilter.html#SEC41
./ffmpeg -i video.mp4 -vf "crop=640:480,scale=ow:oh" -f mpegts udp://127.0.0.1:1234
I receive an error: Error when evaluating the expression 'oh'
Try this:
./ffmpeg -i video.mp4 -vf "scale=640:ih*640/iw, crop=640:480" -f mpegts udp://127.0.0.1:1234
Above code will first scale the video to 640
and maintain the aspect ratio height,
then crop to 640x480.
I assume you're getting:
Error when evaluating the expression 'oh'.
Maybe the expression for out_w:'ow' or for out_h:'oh' is self-referencing.
Because you try to set the output w/h to the output w/h?! What you want to do is
ffmpeg -i video.mp4 -vf "crop=640:480,scale=iw:ih" -f mpegts udp://127.0.0.1:1234
That is, setting the output w/h to what the input width (iw) and input height (ih) was.
Note that you will get an error if the source video is smaller than what you try to crop to (640:480). You may use ffmpeg's expression syntax to first check if a crop/scale is necessary to avoid this error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With