ffmpeg 視頻過分濾鏡 gltransition

ffmpeg 視頻過分濾鏡 gltransition

上次隨筆中提到的 ffmpeg-concat 能夠處理視頻過分,可是缺點是臨時文件超大。
通過查找 ffmpeg 還有 gltransition 濾鏡,可是 ffmpeg 的正式版中尚未加進去。
github 上有 ffmpeg-gl-transition 項目,有詳細的添加濾鏡的說明,參見如下地址
https://github.com/transitive-bullshit/ffmpeg-gl-transition

這個濾鏡依賴的庫包括 GLEW + glfw3
想靜態編譯 GLEW 須要加 #define GLEW_STATIC

ffmpeg -i 1.mp4 -i 2.mp4 -filter_complex "gltransition=duration=4:offset=1.5:source=crosswarp.glsl" -y out.mp4

經過下面的腳本能夠使用不一樣視頻過分方式
-------------------------------------------------------------------------------------------------
ffmpeg-gl-transition-concat.sh
-------------------------------------------------------------------------------------------------
#!/bin/bash
# Example of concatenating 3 mp4s together with 1-second transitions between them.

tpath="/ffmpeg/transitions/"
x264="-look_ahead 0 -ac 2 -c:v h264_qsv -profile:v high -level 3.1 -preset:v veryfast"
ki="-keyint_min 72 -g 72 -sc_threshold 0"
br="-b:v 3000k -minrate 3000k -maxrate 6000k -bufsize 6000k -b:a 128k"

ffmpeg -hide_banner \
  -i 1.mp4 \
  -i 2.mp4 \
  -i 3.mp4 \
  -filter_complex " \
    [0:a]   atrim=0:5  [a0]; \
    [1:a]   atrim=0:5  [a1]; \
    [2:a]   atrim=0:6  [a2]; \
    \
	[0:v]   split  [v000] [v010]; \
    [1:v]   split  [v100] [v110]; \
    [2:v]   split  [v200] [v210]; \
	\
    [v000]  trim=0:5                [v001];  \
    [v010]  trim=5:6                [v011t]; \
    [v011t] setpts=PTS-STARTPTS     [v011];  \
	\
    [v100]   trim=0:5               [v101];  \
    [v110]   trim=5:6               [v111t]; \
    [v111t]  setpts=PTS-STARTPTS    [v111];  \
	\
    [v200]     trim=0:5             [v201];  \
    [v210]     trim=5:6             [v211t]; \
    [v211t]    setpts=PTS-STARTPTS  [v211];  \
	\
    [v011] [v101] gltransition=duration=1:source=${tpath}WaterDrop.glsl  [vt0]; \
    [v111] [v201] gltransition=duration=1:source=${tpath}crosswarp.glsl  [vt1]; \
    \
	[v001] [vt0] [vt1] [v211]  concat=n=4          [outv]; \
	[a0] [a1] [a2]             concat=n=3:v=0:a=1  [outa]" \
  -map [outv] -map [outa] \
  ${x264} ${ki} ${br} \
  -y ffmpeg-gl-transition-concat.mp4
-------------------------------------------------------------------------------------------------
相關文章
相關標籤/搜索