MAC M1系统编译ffmpeg-gl-transition
- 1. 本人系统
- 2. 编译💰系统准备
- 2.1. 下载【ffmpeg-gl-transition】到用户家目录下,并解压
- 2.2 下载ffmpeg源码
- 2.3. brew安装GLEW + glfw3
- 2.4 复制vf_gltransition.c文件到ffmpeg
- 2.5 修改ffmpeg源码文件
- 2.6 设置库目录和头文件目录
- 3. configure & make
- 4. 结果验证
- 4.1 使用方法
参考文档:
【gl-transitions配置】原项目dockerfile修改,为视频添加转场效果
【gitee】 ffmpeg-gl-transition
1. 本人系统
2. 编译💰系统准备
2.1. 下载【ffmpeg-gl-transition】到用户家目录下,并解压
(base) ~/ffmpeg-gl-transition/ ll
total 88
-rw-rw-r--@ 1 admin staff 2.8K 9 6 2019 Dockerfile
-rw-rw-r--@ 1 admin staff 9.2K 9 6 2019 README.md
-rw-rw-r--@ 1 admin staff 851B 9 6 2019 concat.sh
-rw-rw-r--@ 1 admin staff 164B 9 6 2019 crosswarp.glsl
-rw-rw-r--@ 1 admin staff 1.0K 9 6 2019 ffmpeg.diff
drwxrwxr-x@ 7 admin staff 224B 9 6 2019 media
-rw-rw-r--@ 1 admin staff 15K 9 6 2019 vf_gltransition.c
2.2 下载ffmpeg源码
我看网上都是说的ffmpeg-4.2.2
。因此我也是下载的ffmpeg-4.2.2
wget http://www.ffmpeg.org/releases/ffmpeg-4.2.2.tar.gz
tar -zxvf ffmpeg-4.2.2.tar.gz
cd ffmpeg-4.2.2
# get ffmpeg sources
(base) ~/software/ffepeg/ wget http://www.ffmpeg.org/releases/ffmpeg-4.2.2.tar.gz
(base) ~/software/ffepeg/ tar -zxvf ffmpeg-4.2.2.tar.gz
(base) ~/software/ffepeg/ ll
total 26752
drwx------ 45 admin staff 1.4K 6 14 20:44 ffmpeg-4.2.2
-rw-r--r-- 1 admin staff 13M 1 1 2020 ffmpeg-4.2.2.tar.gz
(base) ~/software/ffepeg/
(base) ~/software/ffepeg/ cd ffmpeg-4.2.2
(base) ~/software/ffepeg/ffmpeg-4.2.2/
2.3. brew安装GLEW + glfw3
(base) ~/software/ffepeg/ brew install glew glfw
(base) ~/software/ffepeg/
(base) ~/software/ffepeg/ brew list glew
/opt/homebrew/Cellar/glew/2.2.0_1/bin/glewinfo
/opt/homebrew/Cellar/glew/2.2.0_1/bin/visualinfo
/opt/homebrew/Cellar/glew/2.2.0_1/include/GL/ (3 files)
/opt/homebrew/Cellar/glew/2.2.0_1/lib/libGLEW.2.2.0.dylib
/opt/homebrew/Cellar/glew/2.2.0_1/lib/cmake/ (4 files)
/opt/homebrew/Cellar/glew/2.2.0_1/lib/pkgconfig/glew.pc
/opt/homebrew/Cellar/glew/2.2.0_1/lib/ (3 other files)
/opt/homebrew/Cellar/glew/2.2.0_1/sbom.spdx.json
/opt/homebrew/Cellar/glew/2.2.0_1/share/doc/ (20 files)
(base) ~/software/ffepeg/
(base) ~/software/ffepeg/ brew list glfw
/opt/homebrew/Cellar/glfw/3.4/include/GLFW/ (2 files)
/opt/homebrew/Cellar/glfw/3.4/lib/libglfw.3.4.dylib
/opt/homebrew/Cellar/glfw/3.4/lib/cmake/ (4 files)
/opt/homebrew/Cellar/glfw/3.4/lib/pkgconfig/glfw3.pc
/opt/homebrew/Cellar/glfw/3.4/lib/ (3 other files)
/opt/homebrew/Cellar/glfw/3.4/sbom.spdx.json
/opt/homebrew/Cellar/glfw/3.4/share/doc/ (204 files)
2.4 复制vf_gltransition.c文件到ffmpeg
(base) ~/software/ffepeg/ffmpeg-4.2.2/ cp ~/ffmpeg-gl-transition/vf_gltransition.c libavfilter/
2.5 修改ffmpeg源码文件
- 修改点
通过cat ~/ffmpeg-gl-transition/ffmpeg.diff
我们可以看到有两个文件要改。
libavfilter/Makefile
libavfilter/allfilters.c
这个我就不说了,git大家应该都熟悉。
(base) ~/ffmpeg-gl-transition/ cat ffmpeg.diff
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index a90ca30ad7..c0fc73be46 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -367,6 +367,7 @@ OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.oOBJS-$(CONFIG_ZMQ_FILTER) += f_zmq.oOBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.oOBJS-$(CONFIG_ZSCALE_FILTER) += vf_zscale.o
+OBJS-$(CONFIG_GLTRANSITION_FILTER) += vf_gltransition.oOBJS-$(CONFIG_ALLRGB_FILTER) += vsrc_testsrc.oOBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 6eac828616..0570c1c2aa 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -357,6 +357,7 @@ extern AVFilter ff_vf_yadif;extern AVFilter ff_vf_zmq;extern AVFilter ff_vf_zoompan;extern AVFilter ff_vf_zscale;
+extern AVFilter ff_vf_gltransition;extern AVFilter ff_vsrc_allrgb;extern AVFilter ff_vsrc_allyuv;
(base) ~/ffmpeg-gl-transition/
2.6 设置库目录和头文件目录
export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib
3. configure & make
./configure --enable-libx264 --enable-gpl --enable-opengl \--enable-filter=gltransition --extra-libs='-lGLEW -lglfw'
make
不指定库目录,configure会抛错ffmpeg gcc is unable to create an executable file C compiler test failed
。如下。其实从ffbuild/config.log
文件可以看到是无法连接到GLEW
gcc is unable to create an executable file.
If gcc is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file “ffbuild/config.log” produced by configure as this will help
solve the problem.
不指定头文件目录,make会抛错fatal error: 'GLFW/glfw3.h' file not found
4. 结果验证
make没有异常后,可以看到只有二进制文件生成的。
./ffmpeg -v 0 -filters | grep gltransition
(base) ~/software/ffepeg/ffmpeg-4.2.2/ ./ffmpeg -v 0 -filters | grep gltransitionT.. gltransition VV->V OpenGL blend transitions
(base) ~/software/ffepeg/ffmpeg-4.2.2/
(base) ~/software/ffepeg/ffmpeg-4.2.2/
(base) ~/software/ffepeg/ffmpeg-4.2.2/
(base) ~/software/ffepeg/ffmpeg-4.2.2/ cp -r ~/ffmpeg-gl-transition ./
(base) ~/software/ffepeg/ffmpeg-4.2.2/ ll
...
drwxr-xr-x 18 admin staff 576B 1 1 2020 compat
-rw-r--r-- 1 admin staff 77K 6 14 20:22 config.h
-rwxr-xr-x 1 admin staff 246K 1 1 2020 configure
drwxr-xr-x 149 admin staff 4.7K 6 14 20:40 doc
drwxr-xr-x 13 admin staff 416B 6 14 20:22 ffbuild
-rwxr-xr-x 1 admin staff 17M 6 14 20:40 ffmpeg
drwxr-xr-x@ 10 admin staff 320B 6 14 20:42 ffmpeg-gl-transition
-rwxr-xr-x 1 admin staff 20M 6 14 20:40 ffmpeg_g
-rwxr-xr-x 1 admin staff 17M 6 14 20:40 ffprobe
-rwxr-xr-x 1 admin staff 20M 6 14 20:40 ffprobe_g
drwxr-xr-x 29 admin staff 928B 6 14 20:40 fftools
drwxr-xr-x 3152 admin staff 99K 6 14 20:40 libavcodec
...
4.1 使用方法
- 默认选项:
./ffmpeg -i ffmpeg-gl-transition/media/0.mp4 -i ffmpeg-gl-transition/media/1.mp4 -filter_complex gltransition -y out.mp4
(base) ~/software/ffepeg/ffmpeg-4.2.2/ ./ffmpeg -i ffmpeg-gl-transition/media/0.mp4 -i ffmpeg-gl-transition/media/1.mp4 -filter_complex gltransition -y out.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developersbuilt with Apple clang version 13.0.0 (clang-1300.0.29.30)configuration: --enable-libx264 --enable-gpl --enable-opengl --enable-filter=gltransition --extra-libs='-lglew -lglfw'libavutil 56. 31.100 / 56. 31.100libavcodec 58. 54.100 / 58. 54.100libavformat 58. 29.100 / 58. 29.100libavdevice 58. 8.100 / 58. 8.100libavfilter 7. 57.100 / 7. 57.100
...
- 自定义选项:
./ffmpeg -i media/0.mp4 -i media/1.mp4 -filter_complex "gltransition=duration=4:offset=1.5:source=crosswarp.glsl" -y out.mp4
效果