2

I am using ffmpeg to scale video files to fit within a size of 1280:720, maintaining aspect ratio, using the below commands. This works most of the time, but every now and then a video with a weird aspect ratio comes out to a scale that is not a multiple of 2 in one of the dimensions, which throws an error when encoding to h.264. Is there a way I can keep the same scaling logic but round off that dimension to a multiple of 2?

By way of example I am currently erroring on a video which is 4:3 720:486 - which scales to 1067:720.

-i input.mov -c:v libx264 -vf scale=w=1280:h=720:force_original_aspect_ration=decrease output.mov

1 Answer 1

2

The scale filter has an option called force_divisible_by for this,

scale=w=1280:h=720:force_original_aspect_ration=decrease:force_divisible_by=2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.