gpt4 book ai didi

FFMPEG SET ZxY 宽度和高度缩略图,同时保持纵横比和填充

转载 作者:行者123 更新时间:2023-12-04 22:49:40 25 4
gpt4 key购买 nike

我一直在寻找有关如何使用 ffmpeg 制作缩略图的代码的堆栈溢出。
但是我发现的两种变体要么是带有固定框架的 -s 100x100 - 以扭曲的缩略图结尾;或使用-vf 100:-1,它只适本地缩放图像的一侧——对我来说是个问题,因为所有缩略图都必须具有相同的大小!有没有办法两全其美?
具有恒定比率的设定高度/宽度?喜欢用黑匣子或其他东西划线吗?

最佳答案

https://trac.ffmpeg.org/wiki/Scaling%20(resizing)%20with%20ffmpeg

Sometimes there is a need to scale the input image in such way it fits into a specified rectangle, i.e. if you have a placeholder (empty rectangle) in which you want to scale any given image. This is a little bit tricky, since you need to check the original aspect ratio, in order to decide which component to specify and to set the other component to -1 (to keep the aspect ratio). For example, if we would like to scale our input image into a rectangle with dimensions of 320x240, we could use something like this:


ffmpeg -i input.jpg -vf scale="'if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'" output_320x240_boxed.png

关于FFMPEG SET ZxY 宽度和高度缩略图,同时保持纵横比和填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24820023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com