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

后端 未结 1 1781
醉梦人生
醉梦人生 2021-01-15 18:39

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:

Wh

相关标签:
1条回答
  • 2021-01-15 19:01

    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.

    0 讨论(0)
提交回复
热议问题