Skip to content

Instantly share code, notes, and snippets.

@tlightsky
Created June 30, 2016 10:34
Show Gist options
  • Save tlightsky/8cc1be962e698d4c7dbd459f972a437d to your computer and use it in GitHub Desktop.
Save tlightsky/8cc1be962e698d4c7dbd459f972a437d to your computer and use it in GitHub Desktop.
转换成910x512并加上白边
ffmpeg -i 1.wmv -vf 'scale=910:512,pad=1152:512:121:0:white' 2.mp4
@tlightsky
Copy link
Author

tlightsky commented Jun 30, 2016

使用FFmpeg给视频增加黑边需要用到 pad 这个滤镜,具体用法如下:
-vf pad=1280:720:0:93:black

按照从左到右的顺序依次为:
​ “宽”、“高”、“X坐标”和“Y坐标”,宽和高指的是输入视频尺寸(包含加黑边的尺寸),XY指的是视频所在位置。

比如一个输入视频尺寸是1280x534的源,想要加上黑边变成1280x720,那么用上边的语法可以实现,93是这样得来的,(720-534)/2。

如果视频原始1920x800的话,完整的语法应该是:
-vf 'scale=1280:534,pad=1280:720:0:93:black'

先将视频缩小到1280x534,然后在加入黑边变成1280x720,将1280x534的视频放置在x=0,y=93的地方,
​FFmpeg会自动在上下增加93像素的黑边。
注:black可以不写,默认是黑色

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment