维持FFMPEG宽高比 [英] Maintaining FFMPEG aspect ratio

查看:770
本文介绍了维持FFMPEG宽高比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用ffmpeg转换一堆视频文件。我运行一个bash文件,可以很好地转换所有的文件,但是如果转换的文件不是16:9格式,则会出现问题。当我将屏幕尺寸固定为-s 720x400时,如果原稿的宽高比为4:3,ffmpeg会创建一个16:9的输出文件,从而缩小宽高比。

I need to convert a bunch of video files using ffmpeg. I run a bash file that converts all the files nicely, however there is a problem if a file converted is not in 16:9 format. As I am fixing the size of the screen to -s 720x400, if the aspect ratio of the original is 4:3, the ffmpeg creates a 16:9 output file, screwing the aspect ratio.

是否有一个设置可以将宽高比设置为主要参数,调整大小(例如,仅通过固定X或Y尺寸)? p>

Is there a setting that allows setting an aspect ratio as the main parameter, with size being adjusted (for example, by fixing an X or Y dimension only)?

推荐答案

很久以前我问过这个问题,但实际上我已经得到了一个我当时不知道的解决方案 - 为了保持宽高比,您应该使用视频过滤器,这是一个非常强大的过滤器。

I've asked this a long time ago, but I've actually got a solution which was not known to me at the time -- in order to keep the aspect ratio, you should use the video filter scale, which is a very powerful filter.

您可以直接使用它:

-vf "scale=640:-1" 

这将修复宽度和提供保持方面所需的高度比。但您也可以使用许多其他选项,甚至数学功能,请查看文档 - http://ffmpeg.org /ffmpeg.html#scale

Which will fix the width and supply the height required to keep the aspect ratio. But you can also use many other options and even mathematical functions, check the documentation here - http://ffmpeg.org/ffmpeg.html#scale

这篇关于维持FFMPEG宽高比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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