【FFmpeg】Common command

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 
相关推荐
≮傷£≯√12 小时前
移植ffmpeg 到 GEC6818
ffmpeg
海带紫菜菠萝汤2 天前
FFmpeg.wasm 实践:在浏览器中运行 FFmpeg 的能力边界与性能瓶颈
前端·javascript·ffmpeg·音视频·wasm
程序员老陆3 天前
FFmpeg6的滤镜函数解析
ffmpeg·音视频·avfilter
看浪的路人3 天前
第10讲:Python 调用 FFmpeg 批量处理——打造你的视频处理工具箱
python·ffmpeg·音视频
程序员老陆4 天前
FFmpeg 时间戳全解:从 av_rescale_q 到时间基黑洞
ffmpeg·音视频·时间基
水獭比特4 天前
自动成片没报错,为什么音画还会漂?
ffmpeg
Yeauty4 天前
2026 年在 Rust 里处理音视频,该走哪条路?
rust·ffmpeg·音视频·视频
勿忘初心12215 天前
【Windows流媒体实战1】FFmpeg+Nginx-RTMP Windows详细搭建教程
ffmpeg·nginx-rtmp·windows流媒体搭建·rtmp直播
勿忘初心12215 天前
【Windows流媒体实战2】SpringBoot2.x 整合FFmpeg 完整实操教程
ffmpeg·springboot·流媒体开发·nginx-rtmp·rtmp视频录制
Yeauty8 天前
你那条 ffmpeg 命令,一键翻成 Rust builder 代码
开发语言·rust·ffmpeg