
我想有條件地模糊視頻,例如 30 秒的視頻,形成 2-10 秒模糊不同區域而不是 12-20 秒。
但到目前為止我只能模糊它 1 次,以下是我嘗試實現目標的命令。使用算術表達式
ffmpeg -y -i with_out_sound.mp4 filter_complex [0:v]boxblur=10:enable='between(t,2,10)'[bg],[0:v]crop=206:169:3 2:121[fg],[bg][fg]overlay=32:121:enable='between(t,2,10)'[tmp];[0:v]boxblur=10: enable='between(t,12,20)'[bg],[0:v]crop=206:169:42:100[fg],[bg][fg]overlay=42:100 :enable='between(t,12,20)'[tmp2];[tmp][tmp2]concat[tmp3] -map [tmp3] with_out_sou ndd.mp4
但上面的命令首先模糊(2-10)完整視頻,然後再次用模糊(12-20)連接完整視頻,所以我得到 60 秒視頻而不是 30 秒。
ffmpeg -y -i with_out_sound.mp4 -filter_complex [0:v]boxblur=10:enable='between(t,2,10)'[bg];[bg]crop=206:169:32:121[fg];[bg][fg]overlay=32:121:enable='between(t,2,10)'[tmp],[tmp]b oxblur=10:enable='between(t,12,20)'[tbg],[tmp]crop=206:169:42:100[tfg],[tbg][tfg]overlay=42:100:enable='between(t,12,20)'[tmp2] -map "[tmp2]" with_out_soundd.mp4
但在這種情況下,我開始收到錯誤流說明符“tmp”在過濾器圖描述中不匹配任何流。
我在 Windows 上使用 ffmpeg 最新版本。
答案1
使用
ffmpeg -y -i with_out_sound.mp4 -filter_complex \
"[0:v]boxblur=10:enable='if(between(t,2,10)+between(t,12,20),1,0)'[bg];
[0:v]crop=206:169:32:121[fg1];[0:v]crop=206:169:42:100[fg2];
[bg][fg1]overlay=32:121:enable='between(t,2,10)'[tmp];
[tmp][fg2]overlay=42:100:enable='between(t,12,20)'[tmp2]"
-map [tmp2] with_blur.mp4
你可以添加在一個濾鏡執行中使用多個條件進行模糊,然後使用兩個疊加。避免了連接。如果你想使用 concat,你應該修剪兩個流,但這更容易。
使用的條件是if true 則if(x,y,z)
評估x
並傳回else 。y
z