关于FFmpeg:FFmpeg-使用宽高比更改视频的分辨率

FFmpeg - Change resolution of the video with aspect ratio

所有。

如何使用FFmpeg使用宽高比更改视频的分辨率?

有选择
http://manpages.ubuntu.com/manpages/oneiric/man1/ffmpeg.1.html

1
2
3
4
       -s size
       Set frame size. The format is wxh (ffserver default = 160x128,
       ffmpeg default = same as source).  The following abbreviations are
       recognized:

1
2
3
4
5
6
7
       -aspect aspect
       Set the video display aspect ratio specified by aspect.

       aspect can be a floating point number string, or a string of the
       form num:den, where num and den are the numerator and denominator
       of the aspect ratio. For example"4:3","16:9","1.3333", and
      "1.7777" are valid argument values.

例如,我有两个输入视频:

  • 200 * 400分辨率
  • 400 * 700分辨率

我需要以100 * 200的分辨率制作输出视频。

如果我使用-s 100x200运行ffmpeg,则第二个视频的宽高比将变差。

如何通过宽度限制输出视频,如何通过高度限制自动宽高比?

例如,我只想为输出视频指定宽度100px,而ffmpeg必须自动以正确的宽高比计算高度。

对于第一个视频,它将是:

200/100 = 2

400/2 = 200

即100x200

对于第二个视频,它将是:

400/100 = 4

700/4 = 75

即100x75

可能吗?


ffmpeg -i -vf scale=720x406,setdar=16:9


不适用于视频。该页面仅处理静止图像。

出于尚未完全理解的原因,FFMPEG围绕着"采样/像素长宽比"(Sample / Pixel Aspect Ratio)四处游荡,将视频恢复为原始长宽比。例如,如果将视频拉伸两倍,则宽高比将变为1:2或类似的比例(2:1?)

因此,如果您真的想将视频扩展为" Stretch Armstrong"风格,则需要强制使用SAR(采样宽高比):

1
ffmpeg -i <something> -vf scale=iw*55:ih,setsar=1:1 ...

FFMPEG手册中对此的描述不是很好,这是一个video.stackexchange答案,将其全部放在一个位置。


使用幻数-1按比例调整视频大小,并且setdar需要使用斜杠/作为分隔符而不是冒号:

1
ffmpeg -i <input> -vf"scale=100:-1,setdar=16/9" <output>

该命令将使用宽高比16:9将视频200x400调整为100x200,将400x700调整为100x175


下面提到两个选项:
与规模:

1
ffmpeg -i source.mp4 -r 15 -s 320x240 -strict -2 destination.mp4

使用长宽比:

1
ffmpeg -i source.mp4 -r 15 -aspect 1:1 -strict -2 destination.mp4