Using this command:
ffmpeg -loop 1 -r 1 -i q.jpg -t 5 -pix_fmt yuv420p -vf 'scale=-2:min(1080\,ih)' z.mp4
I get this message:
[libx264 @ 00000000004d0ec0] height not divisible by 2 (954x953)
I can avoid the error like this:
ffmpeg -loop 1 -r 1 -i q.jpg -t 5 -pix_fmt yuv420p -vf scale=-2:1080 z.mp4
However this is not ideal because it is upscaling the image. How can I scale the image only if the height is greater than 1080, while keeping the pixel format as I have it?