[FFmpeg-user] ffmpeg keep aspect ratio when scaling, keep dimensions divisable by n
atticus
mail-login+ffmpeg at protonmail.com
Thu Apr 9 12:36:35 EEST 2020
Hi there,
I'm scaling a video by with this filter:
-vf "scale=720:320:force_original_aspect_ratio=decrease"
which works perfectly fine, since I can input the my desired resolution and
ffmpeg decides on its own which dimension should be scaled by how much to
keep the aspect ratio. The problem now is that in some cases ffmpeg will
calculate a uneven number for one of the dimensions (with the h264 codec)
thus I get this error:
[libx264 @ 0x5633df10bcc0] width not divisible by 2 (569x320)
Error initializing output stream 0:0 -- Error while opening encoder for
output stream #0:0 - maybe incorrect parameters such as bit_rate, rate,
width or height
Is there some way to prevent this to give ffmpeg a width and a height as an
input and it says on its own which should be scaled by how much AND keep (at
least the calculated) dimensions divisable by n (I know something similar is
possible with negative numbers, but then I can only give one dimension)?
I tried something like this as well, but I don't know if ffmpeg even can
calculate modulo and if this isn't a problem with self referencing:
-vf
"scale=720:320:force_original_aspect_ratio=decrease:w=ow+(ow%2):h=oh+(oh%2)"
--
Sent from: http://www.ffmpeg-archive.org/
More information about the ffmpeg-user
mailing list