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 -------------------------------------------------------------------------------------------------