There are lots of questions on SO about resizing video but they all seem to assume orientation. Let’s say that I am ingesting user videos and sometimes they are horizontal and sometimes vertical. I’d like to downscale them to at most 1920×1080 or 1080×1920, depending on orientation, but never upscale. I can’t examine videos ahead of time so I am looking for a filter command that will do all this logic in one go. Anyone have anything like this handy?
This command would check the videos orientation and would scale it accordingly.
ffmpeg -i input.mp4 -vf "scale='if(gte(iw,ih),min(1920,iw),-2)':'if(gte(iw,ih),-2,min(1080,ih))'" -c:a copy output.mp4
yehuda r is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.