使用 ffmpeg 为 Android 编译 x265 并收到错误
Compiling x265 with ffmpeg for Android and receiving errors
正在尝试编译 x265 以用于 arm64-v8a。成功构建 x265 本身后,我在 ffmpeg 即将编译时收到以下错误:
require_pkg_config libx265 x265 x265.h x265_api_get
check_pkg_config libx265 x265 x265.h x265_api_get
test_pkg_config libx265 x265 x265.h x265_api_get
/root/ffmpeg_android/ffmpeg-android-1.6.3/ffmpeg-pkg-config --exists --print-errors x265
check_func_headers x265.h x265_api_get -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -lx265
test_ld cc -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -lx265
test_cc -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib
BEGIN /tmp/ffconf.xKyjnplW/test.c
1 #include <x265.h>
2 #include <stdint.h>
3 long check_x265_api_get(void) { return (long) x265_api_get; }
4 int main(void) { int ret = 0;
5 ret |= ((intptr_t)check_x265_api_get) & 0xFFFF;
6 return ret; }
END /tmp/ffconf.xKyjnplW/test.c
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/aarch64-linux-android-clang -DANDROID -fpic -fpie -march=armv8-a --sysroot=/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/sysroot -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -DANDROID -fpic -fpie -march=armv8-a -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/vpx/android/arm64-v8a/include -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x264/android/arm64-v8a/include/x264 -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/lame/android/arm64-v8a/include -DANDROID -fpic -fpie -march=armv8-a --static -mcpu=cortex-a57 -std=c11 -fPIE -fomit-frame-pointer -fPIC -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -c -o /tmp/ffconf.xKyjnplW/test.o /tmp/ffconf.xKyjnplW/test.c
clang60: warning: argument unused during compilation: '-L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib' [-Wunused-command-line-argument]
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/aarch64-linux-android-clang -Wl,-z,defs -Wl,--unresolved-symbols=report-all -march=armv8-a -L/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/sysroot -Wl,-z,relro -Wl,-z,now -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/vpx/android/arm64-v8a/lib -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x264/android/arm64-v8a/lib -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/lame/android/arm64-v8a/lib -Wl,-z,defs -Wl,--unresolved-symbols=report-all -march=armv8-a -L/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/sysroot -Wl,-z,relro -Wl,-z,now --static --sysroot=/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/sysroot -mcpu=cortex-a57 -Wl,--as-needed -Wl,-z,noexecstack -fPIE -pie -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -o /tmp/ffconf.xKyjnplW/test /tmp/ffconf.xKyjnplW/test.o -lx265 -lgcc
clang60: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib/libx265.a when searching for -lx265
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib/libx265.a when searching for -lx265
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lx265
clang60: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: x265 not found using pkg-config
我使用 ffmpeg 4.1.3 和最新版本的 x265 源代码。我使用 this 项目进行编译,在没有 x265 的情况下构建时我已经成功了。我在 Debian Buster x64 上编译。
我最终使用了 this 项目中的脚本,该项目使用所有最新的 NDK 和 ffmpeg 以及每个最新的库,以创建一个 ffmpeg 二进制文件。它在我的设备上运行良好,通过稍微修改,我也得到了一个静态 ffmpeg。我只需要向我的应用程序添加 2 个额外的本机库即可使其正常工作。它甚至使用所有 CPU 功能,因此它是最快的移动解决方案。
正在尝试编译 x265 以用于 arm64-v8a。成功构建 x265 本身后,我在 ffmpeg 即将编译时收到以下错误:
require_pkg_config libx265 x265 x265.h x265_api_get
check_pkg_config libx265 x265 x265.h x265_api_get
test_pkg_config libx265 x265 x265.h x265_api_get
/root/ffmpeg_android/ffmpeg-android-1.6.3/ffmpeg-pkg-config --exists --print-errors x265
check_func_headers x265.h x265_api_get -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -lx265
test_ld cc -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -lx265
test_cc -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib
BEGIN /tmp/ffconf.xKyjnplW/test.c
1 #include <x265.h>
2 #include <stdint.h>
3 long check_x265_api_get(void) { return (long) x265_api_get; }
4 int main(void) { int ret = 0;
5 ret |= ((intptr_t)check_x265_api_get) & 0xFFFF;
6 return ret; }
END /tmp/ffconf.xKyjnplW/test.c
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/aarch64-linux-android-clang -DANDROID -fpic -fpie -march=armv8-a --sysroot=/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/sysroot -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -DANDROID -fpic -fpie -march=armv8-a -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/vpx/android/arm64-v8a/include -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x264/android/arm64-v8a/include/x264 -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/lame/android/arm64-v8a/include -DANDROID -fpic -fpie -march=armv8-a --static -mcpu=cortex-a57 -std=c11 -fPIE -fomit-frame-pointer -fPIC -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -c -o /tmp/ffconf.xKyjnplW/test.o /tmp/ffconf.xKyjnplW/test.c
clang60: warning: argument unused during compilation: '-L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib' [-Wunused-command-line-argument]
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/aarch64-linux-android-clang -Wl,-z,defs -Wl,--unresolved-symbols=report-all -march=armv8-a -L/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/sysroot -Wl,-z,relro -Wl,-z,now -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/vpx/android/arm64-v8a/lib -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x264/android/arm64-v8a/lib -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/lame/android/arm64-v8a/lib -Wl,-z,defs -Wl,--unresolved-symbols=report-all -march=armv8-a -L/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/sysroot -Wl,-z,relro -Wl,-z,now --static --sysroot=/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/sysroot -mcpu=cortex-a57 -Wl,--as-needed -Wl,-z,noexecstack -fPIE -pie -I/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/include/x265 -L/root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib -o /tmp/ffconf.xKyjnplW/test /tmp/ffconf.xKyjnplW/test.o -lx265 -lgcc
clang60: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib/libx265.a when searching for -lx265
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /root/ffmpeg_android/ffmpeg-android-1.6.3/jni/x265/android/arm64-v8a/lib/libx265.a when searching for -lx265
/root/ffmpeg_android/ffmpeg-android-1.6.3/toolchain-android/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lx265
clang60: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: x265 not found using pkg-config
我使用 ffmpeg 4.1.3 和最新版本的 x265 源代码。我使用 this 项目进行编译,在没有 x265 的情况下构建时我已经成功了。我在 Debian Buster x64 上编译。
我最终使用了 this 项目中的脚本,该项目使用所有最新的 NDK 和 ffmpeg 以及每个最新的库,以创建一个 ffmpeg 二进制文件。它在我的设备上运行良好,通过稍微修改,我也得到了一个静态 ffmpeg。我只需要向我的应用程序添加 2 个额外的本机库即可使其正常工作。它甚至使用所有 CPU 功能,因此它是最快的移动解决方案。