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

问题描述 投票:11回答:4

所有。

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

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

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

       -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

可能吗?

video ffmpeg resolution aspect-ratio
4个回答
15
投票

ffmpeg -i <input> -vf scale=720x406,setdar=16:9 <output>

了解更多信息,

Changing-resolution-video-using-ffmpeg


8
投票

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

由于未完全理解的原因,FFMPEG使用样本/像素宽高比来调整视频以恢复原始宽高比。例如,如果您将视频拉出两倍宽,它会使宽高比为1:2,或类似的东西(2:1?)

因此,如果您真的想要将视频拉伸为“Stretch Armstrong”样式,则需要强制SAR(样本纵横比):

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

这在FFMPEG手册here's a video.stackexchange answer that puts it all in one place.中并没有得到很好的描述


1
投票

以下两个选项:with Scale:

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

使用宽高比:

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

1
投票

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

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

该命令将调整视频200x400100x200400x700100x175与纵横比16:9

© www.soinside.com 2019 - 2024. All rights reserved.