1.视频拼接
1)多视频拼接
bash
创建1.txt
file '1.mp4'
file '2.mp4'
file '3.mp4'
file '4.mp4'
运行
bash
ffmpeg -f concat -safe 0 -i "1.txt" -c copy "output6.mp4"
2.音量调节
1)简单调节
bash
ffmpeg -i bg.mp3 -i output6.mp4 -filter_complex "[0:a]volume=0.3[a1];[1:a]volume=1.5[a2];[a2][a1]amix=inputs=2:duration=first" -y BGM.mp4
2)音量归一化
对每个视频进行:
bash
ffmpeg -i input1.mp4 -af loudnorm=I=-16:TP=-1.5:LRA=11:measured_I=-22.3:measured_TP=-1.0:measured_LRA=10.5:measured_thresh=-32.0:linear=true:print_format=summary normalized_output1.mp4
最后拼接在一起
3.字幕添加
bash
ffmpeg -y -i output2.mp4 -vf subtitles=2.ass 2.mp4
4.转场
1)Xfade
https://trac.ffmpeg.org/wiki/Xfade
bash
ffmpeg -loop 1 -t 5 -i 1.png -loop 1 -t 5 -i 2.png -filter_complex "[0][1]xfade=transition=fade:duration=1:offset=4,format=yuv420p" output.mp4
2)gl-transitions
GL Transitions (gl-transitions.com)
环境配置
bash
Xvfb :1 -screen 0 1280x1024x16
export DISPLAY=:99
ffmpeg -i 0.mp4 -i 1.mp4 -filter_complex "gltransition=duration=4:offset=1.5:source=crosswarp.glsl" -y out.mp4
5.生成黑色视频以及字幕ass转GIF
生成黑色视频
bash
ffmpeg -f lavfi -i color=c=black:s=720x1280:d=10 -c:v libx264 -tune stillimage -pix_fmt yuv420p output_black.mp4
ass转gif
bash
ffmpeg -i output_black.mp4 -vf "subtitles=1.ass:force_style='Alignment=2',format=rgba" -pix_fmt rgba output.gif -y
gif烧录到视频中
bash
ffmpeg -i DEMO3.mp4 -stream_loop -1 -i output.gif -filter_complex "[1:v]setpts=PTS-STARTPTS+19/TB,colorkey=0x000000:0.3:0.1[v2];[0:v][v2]overlay=0:0:enable='between(t,19,35)':shortest=1" -c:a copy output_with_gif.mp4 -y