Ffmpeg报Error initializing filter ‘gltransition‘这个有问题解决方法

1:安装完ffmpeg后,检测是否安装ffmpeg

执行:ffmpeg

如下是说明没问题

root@hroot-virtual-machine:~/ffmpeg-4.2.2# ffmpeg
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --enable-libx264 --enable-libx265 --enable-libvpx --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-nonfree --enable-gpl --enable-opengl --enable-filter=gltransition --extra-libs='-lGLEW -lglfw -ldl'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

检测是否安装配置gltransition

root@hroot-virtual-machine:~/ffmpeg-4.2.2# ffmpeg -v 0 -filters | grep gltransition
 T.. gltransition      VV->V      OpenGL blend transitions

测试gltransition是否运转成功

//创建一个文件存放素材
# cd /
# mkdir img
# cd img

root@hroot-virtual-machine:/img# ll
总用量 1248
drwxr-xr-x  2 root root   4096 7月   2 11:38 ./
drwxr-xr-x 21 root root   4096 7月   2 10:05 ../
-rw-r--r--  1 root root 185169 7月   2 10:05 1.jpg
-rw-r--r--  1 root root  67524 7月   2 10:05 2.jpg
-rw-r--r--  1 root root 149603 7月   2 10:05 3.jpg
-rw-r--r--  1 root root 188339 7月   2 10:05 4.jpg
-rw-r--r--  1 root root 176810 7月   2 10:05 5.jpg
-rw-r--r--  1 root root 487613 7月   2 10:53 bgm.m4a

查看我们下载的特效文件

root@hroot-virtual-machine:~/ffmpeg-gl-transition/gl-transitions/transitions# ll
总用量 320
drwxr-xr-x 2 root root 4096 7月   1 18:22 ./
drwxr-xr-x 6 root root 4096 7月   1 18:22 ../
-rw-r--r-- 1 root root  462 7月   1 18:22 angular.glsl
-rw-r--r-- 1 root root  752 7月   1 18:22 Bounce.glsl
-rw-r--r-- 1 root root 2593 7月   1 18:22 BowTieHorizontal.glsl
-rw-r--r-- 1 root root 2541 7月   1 18:22 BowTieVertical.glsl
-rw-r--r-- 1 root root 1908 7月   1 18:22 BowTieWithParameter.glsl
-rw-r--r-- 1 root root  245 7月   1 18:22 burn.glsl
-rw-r--r-- 1 root root  981 7月   1 18:22 ButterflyWaveScrawler.glsl
-rw-r--r-- 1 root root  485 7月   1 18:22 cannabisleaf.glsl
-rw-r--r-- 1 root root  550 7月   1 18:22 CircleCrop.glsl
-rw-r--r-- 1 root root  422 7月   1 18:22 circle.glsl
-rw-r--r-- 1 root root  408 7月   1 18:22 circleopen.glsl
-rw-r--r-- 1 root root  392 7月   1 18:22 colorphase.glsl
-rw-r--r-- 1 root root  364 7月   1 18:22 ColourDistance.glsl
-rw-r--r-- 1 root root  627 7月   1 18:22 CrazyParametricFun.glsl
-rw-r--r-- 1 root root  623 7月   1 18:22 crosshatch.glsl
-rw-r--r-- 1 root root  228 7月   1 18:22 crosswarp.glsl
-rw-r--r-- 1 root root 2396 7月   1 18:22 CrossZoom.glsl
-rw-r--r-- 1 root root 1738 7月   1 18:22 cube.glsl
-rw-r--r-- 1 root root  361 7月   1 18:22 directional-easing.glsl
-rw-r--r-- 1 root root  315 7月   1 18:22 Directional.glsl
-rw-r--r-- 1 root root  498 7月   1 18:22 directionalwarp.glsl
-rw-r--r-- 1 root root  577 7月   1 18:22 directionalwipe.glsl
-rw-r--r-- 1 root root  533 7月   1 18:22 displacement.glsl
-rw-r--r-- 1 root root 1627 7月   1 18:22 DoomScreenTransition.glsl
-rw-r--r-- 1 root root 1221 7月   1 18:22 doorway.glsl
-rw-r--r-- 1 root root  378 7月   1 18:22 Dreamy.glsl
-rw-r--r-- 1 root root 1163 7月   1 18:22 DreamyZoom.glsl
-rw-r--r-- 1 root root  413 7月   1 18:22 fadecolor.glsl
-rw-r--r-- 1 root root  136 7月   1 18:22 fade.glsl
-rw-r--r-- 1 root root  558 7月   1 18:22 fadegrayscale.glsl
-rw-r--r-- 1 root root 2231 7月   1 18:22 FilmBurn.glsl
-rw-r--r-- 1 root root  522 7月   1 18:22 flyeye.glsl
-rw-r--r-- 1 root root 2242 7月   1 18:22 GlitchDisplace.glsl
-rw-r--r-- 1 root root  607 7月   1 18:22 GlitchMemories.glsl
-rw-r--r-- 1 root root 2300 7月   1 18:22 GridFlip.glsl
-rw-r--r-- 1 root root  356 7月   1 18:22 heart.glsl
-rw-r--r-- 1 root root 1644 7月   1 18:22 hexagonalize.glsl
-rw-r--r-- 1 root root 7518 7月   1 18:22 InvertedPageCurl.glsl
-rw-r--r-- 1 root root  585 7月   1 18:22 kaleidoscope.glsl
-rw-r--r-- 1 root root  647 7月   1 18:22 LeftRight.glsl
-rw-r--r-- 1 root root  682 7月   1 18:22 LinearBlur.glsl
-rw-r--r-- 1 root root  189 7月   1 18:22 luma.glsl
-rw-r--r-- 1 root root 3812 7月   1 18:22 luminance_melt.glsl
-rw-r--r-- 1 root root  390 7月   1 18:22 morph.glsl
-rw-r--r-- 1 root root 1127 7月   1 18:22 Mosaic.glsl
-rw-r--r-- 1 root root  339 7月   1 18:22 multiply_blend.glsl
-rw-r--r-- 1 root root 1444 7月   1 18:22 perlin.glsl
-rw-r--r-- 1 root root  361 7月   1 18:22 pinwheel.glsl
-rw-r--r-- 1 root root  584 7月   1 18:22 pixelize.glsl
-rw-r--r-- 1 root root  464 7月   1 18:22 polar_function.glsl
-rw-r--r-- 1 root root  326 7月   1 18:22 PolkaDotsCurtain.glsl
-rw-r--r-- 1 root root  364 7月   1 18:22 Radial.glsl
-rw-r--r-- 1 root root  444 7月   1 18:22 randomNoisex.glsl
-rw-r--r-- 1 root root  399 7月   1 18:22 randomsquares.glsl
-rw-r--r-- 1 root root  378 7月   1 18:22 ripple.glsl
-rw-r--r-- 1 root root  878 7月   1 18:22 rotate_scale_fade.glsl
-rw-r--r-- 1 root root  348 7月   1 18:22 rotateTransition.glsl
-rw-r--r-- 1 root root  376 7月   1 18:22 SimpleZoom.glsl
-rw-r--r-- 1 root root  771 7月   1 18:22 squareswire.glsl
-rw-r--r-- 1 root root  455 7月   1 18:22 squeeze.glsl
-rw-r--r-- 1 root root 8015 7月   1 18:22 StereoViewer.glsl
-rw-r--r-- 1 root root 1539 7月   1 18:22 swap.glsl
-rw-r--r-- 1 root root  715 7月   1 18:22 Swirl.glsl
-rw-r--r-- 1 root root 4051 7月   1 18:22 tangentMotionBlur.glsl
-rw-r--r-- 1 root root  650 7月   1 18:22 TopBottom.glsl
-rw-r--r-- 1 root root  651 7月   1 18:22 TVStatic.glsl
-rw-r--r-- 1 root root 1399 7月   1 18:22 undulatingBurnOut.glsl
-rw-r--r-- 1 root root  429 7月   1 18:22 WaterDrop.glsl
-rw-r--r-- 1 root root  397 7月   1 18:22 wind.glsl
-rw-r--r-- 1 root root  274 7月   1 18:22 windowblinds.glsl
-rw-r--r-- 1 root root  299 7月   1 18:22 windowslice.glsl
-rw-r--r-- 1 root root  192 7月   1 18:22 wipeDown.glsl
-rw-r--r-- 1 root root  192 7月   1 18:22 wipeLeft.glsl
-rw-r--r-- 1 root root  192 7月   1 18:22 wipeRight.glsl
-rw-r--r-- 1 root root  192 7月   1 18:22 wipeUp.glsl
-rw-r--r-- 1 root root 1073 7月   1 18:22 ZoomInCircles.glsl

获取到绝对路径

root@hroot-virtual-machine:~/ffmpeg-gl-transition/gl-transitions/transitions# pwd
/root/ffmpeg-gl-transition/gl-transitions/transitions

--------然后回到素材文件夹哪里
cd /img

开始执行测试

ffmpeg \
-t 1 -loop 1 -i 1.jpg \
-t 1 -loop 1 -i 2.jpg \
-filter_complex \
"gltransition=offset=0.5:duration=0.5:source=/root/ffmpeg-gl-transition/gl-transitions/transitions/crosswarp.glsl" \
-y out.mp4

source:后面是特效文件的绝对路径

结果发现:

root@hroot-virtual-machine:/img# ffmpeg \
> -t 1 -loop 1 -i 1.jpg \
> -t 1 -loop 1 -i 2.jpg \
> -filter_complex \
> "gltransition=offset=0.5:duration=0.5:source=/root/ffmpeg-gl-transition/gl-transitions/transitions/crosswarp.glsl" \
> -y out.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --enable-libx264 --enable-libx265 --enable-libvpx --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-nonfree --enable-gpl --enable-opengl --enable-filter=gltransition --extra-libs='-lGLEW -lglfw -ldl'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, image2, from '1.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 37033 kb/s
    Stream #0:0: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 400x400 [SAR 1:1 DAR 1:1], 25 fps, 25 tbr, 25 tbn, 25 tbc
Input #1, image2, from '2.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 13504 kb/s
    Stream #1:0: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 400x400 [SAR 1:1 DAR 1:1], 25 fps, 25 tbr, 25 tbn, 25 tbc
[AVFilterGraph @ 0x565112acce40] Error initializing filter 'gltransition' with args 'offset=0.5:duration=0.5:source=/root/ffmpeg-gl-transition/gl-transitions/transitions/crosswarp.glsl'
Error initializing complex filters.
Operation not permitted

报Error initializing filter 'gltransition'这个有问题

解决方法如下:

安装xvfb(安装过了直接跳过)

sudo apt-get -y install xvfb

然后启动xvfb(线程阻塞)

Xvfb :1 -screen 0 1280x1024x16

接着调用xvfb执行特效

env DISPLAY=:1  ffmpeg 命令

例如刚刚报错的那句:

env DISPLAY=:1 ffmpeg \
	-t 1 -loop 1 -i 1.jpg \
	-t 1 -loop 1 -i 2.jpg \
	-filter_complex \
	"gltransition=offset=0.5:duration=0.5:source=/root/ffmpeg-gl-transition/gl-transitions/transitions/crosswarp.glsl" \
	-y out1.mp4

执行完没有保存说明成功了,我们查看一下:

root@hroot-virtual-machine:/img# ll
	总用量 1336
	drwxr-xr-x  2 root root   4096 7月   2 11:49 ./
	drwxr-xr-x 21 root root   4096 7月   2 10:05 ../
	-rw-r--r--  1 root root 185169 7月   2 10:05 1.jpg
	-rw-r--r--  1 root root  67524 7月   2 10:05 2.jpg
	-rw-r--r--  1 root root 149603 7月   2 10:05 3.jpg
	-rw-r--r--  1 root root 188339 7月   2 10:05 4.jpg
	-rw-r--r--  1 root root 176810 7月   2 10:05 5.jpg
	-rw-r--r--  1 root root 487613 7月   2 10:53 bgm.m4a
	-rw-r--r--  1 root root  89138 7月   2 11:49 out1.mp4	(我们图片加特效合成的视频)

视频添加特效,没有EGL的一定要安装xvfb,用xvfb来添加特效

env DISPLAY=:1 执行命令一定要在前面加这个

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值