ffmpeg如何通过设置高度比例修改后计算宽度? [英] How to have ffmpeg calculate the width after modifying by set height ratio?

查看:567
本文介绍了ffmpeg如何通过设置高度比例修改后计算宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

找到解决方案后,我的Android上所有webm到MP4编解码器转换错误的根源.我遇到另一个问题.要细分我的问题:

After finding the resolution was the source of all my webm to MP4 codec conversion errors on my Android. I came across another problem. To break down my question:

大多数设备支持什么MP4分辨率?我知道他们要从某个高度值上乘以p才能工作.例如720p/?X720.

What all MP4 resolutions are supported on most devices? I know they go by p from certain height value for them to work. 720p /?X720 for example.

是否有更简单的方法可以在保持比例的同时根据高度变化来计算宽度?

Is there an easier way to calculate the width based from the height change while keeping the ratio?

ffmpeg -i old.webm -t 00:00:03 -s 320x240 new.mp4

我目前在我的测试示例中使用-s设置范围.

I currently use the -s setting perimeter from my testing example.

推荐答案

宽屏的标准比例为16:9,使用的典型分辨率列表为

The standard ratio for widescreens is 16:9 and the typical list of resolutions used is

256x144, 426x240, 640x360, 854x480, 960x540, 1024x576, 1280x720, 1920x1080, 2560x1440, 3840x2160

如果直接使用比例过滤器,则可以告诉ffmpeg保持宽高比:

If you directly use the scale filter, you can tell ffmpeg to maintain the aspect ratio:

ffmpeg -i old.webm -t 00:00:03 -vf scale=-2:240 new.mp4

在上面的命令中,scale=-2:240告诉ffmpeg缩放到高度240,选择一个宽度以保持纵横比,然后调整该值以使width& height是2的倍数(H.264/MP4必需).如果您不关心该值是否为偶数,则可以使用-1.

In the command above, scale=-2:240 tells ffmpeg to scale to height 240, select a width so that aspect ratio is maintained, and then adjust that value so that the width & height is a multiple of 2 (required for H.264/MP4). If you did not care whether the value was even, you could just use -1.

这篇关于ffmpeg如何通过设置高度比例修改后计算宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆