ffmpeg命令目录
最终效果
gblur命令参数
Apply Gaussian blur filter.
The filter accepts the following options:
sigma
Set horizontal sigma, standard deviation of Gaussian blur. Default is 0.5.
steps
Set number of steps for Gaussian approximation. Default is 1.
planes
Set which planes to filter. By default all planes are filtered.
sigmaV
Set vertical sigma, if negative it will be same as sigma. Default is -1.
命令
ffmpeg -i 纸短情长.mp4 -filter_complex [0:v]crop=(ih/16*9):ih,scale=iw/10:-2,gblur=sigma=5,scale=720:1280[vbg];[vbg][0:v]overlay=0:(H-h)/2 -y out.mp4
命令解析
输入的原视频是一个1280x720的横屏视频
命令核心在于滤镜filter_complex可以拆解成两部分。
1.背景的生成
2.原视频与背景的叠加
- 生成背景
[0:v]crop=(ih/16*9):ih,scale=iw/10:-2,gblur=sigma=5,scale=720:1280[vbg];
crop=(ih/16*9),从原视频中裁剪出一个竖屏区域作为背景
scale=iw/10:-2,对裁剪后的视频缩小未原来的1/10以便高斯模糊(速度快)
gblur=sigma=5,对缩小后的视频背景进行高斯模糊
scale=720:1280[vbg],对高斯模糊后的视频进行放大,并保存到vbg变量中
- 背景与原视频的叠加
[vbg][0:v]overlay=0:(H-h)/2
overlay的参数x,y。
0为x的坐标
(H-h)/2是y的坐标,也就是高度居中叠加