How to have ffmpeg calculate the width after modifying by set height ratio?

孤街浪徒 提交于 2019-12-01 11:57:41

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

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!