Search code examples
ffmpegscalecrop

ffmpeg: scale output cropped width/height doesn't work


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'


Solution

  • 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.