Maintaining aspect ratio with FFmpeg

前端 未结 8 1338
悲&欢浪女
悲&欢浪女 2021-01-29 22:39

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

相关标签:
8条回答
  • 2021-01-29 23:12

    you can use ffmpeg -i to get the dimensions of the original file, and use that in your commands for the encode. What platform are you using ffmpeg on?

    0 讨论(0)
  • 2021-01-29 23:14

    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.

    You can simply use it like this:

    -vf "scale=640:-1" 
    

    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

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