1: After installing ffmpeg, check whether to install ffmpeg
Implementation: ffmpeg
Here’s the explanation. No problem
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'
Check whether the configuration gltransition is installed
root@hroot-virtual-machine:~/ffmpeg-4.2.2# ffmpeg -v 0 -filters | grep gltransition
T.. gltransition VV->V OpenGL blend transitions
Test whether gltransition runs successfully
//Create a file to store the material
?CD/
?MKDIR img
?CD img
root@hroot-virtual-machine:/img# ll
total 1248
drwxr-xr-x 2 root root 4096 Jul 2 11:38 ./
drwxr-xr-x 21 root root 4096 Jul 2 10:05 ../
-rw-r--r-- 1 root root 185169 Jul 2 10:05 1.jpg
-rw-r--r-- 1 root root 67524 Jul 2 10:05 2.jpg
-rw-r--r-- 1 root root 149603 Jul 2 10:05 3.jpg
-rw-r--r-- 1 root root 188339 Jul 2 10:05 4.jpg
-rw-r--r-- 1 root root 176810 Jul 2 10:05 5.jpg
-rw-r--r-- 1 root root 487613 Jul 2 10:53 bgm.m4a
Check out the special effects files we downloaded
root@hroot-virtual-machine:~/ffmpeg-gl-transition/gl-transitions/transitions# ll
total 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
Get absolute path
root@hroot-virtual-machine:~/ffmpeg-gl-transition/gl-transitions/transitions# pwd
/root/ffmpeg-gl-transition/gl-transitions/transitions
--------Then go back to the material folder where
cd /img
Start the test
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: followed by the absolute path of the special effects file
The results showed that: 1
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’ is a problem
The solution is as follows:
Install xvfb (skip if installed)
sudo apt-get -y install xvfb
Then start xvfb (thread blocking)
Xvfb :1 -screen 0 1280x1024x16
Then call xvfb to execute the special effect
env DISPLAY=:1 ffmpeg 命令
For example, the sentence that just reported an error:
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
If the instructions are not saved after execution, let’s check:
root@hroot-virtual-machine:/img# ll
total 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 (Our picture plus special effects composite video)
Video add special effects, no EGL must install xvfb, with xvfb to add special effects
Env display =: 1 this must be added before executing the command