概述
编译Android下可以使用的ffmpeg
参照视频操作:https://coding.imooc.com/lesson/279.html#mid=37236
其他流程都没有什么问题其中有几个问题我记录一下
1.ERROR: Failed to create toolchain.
解决方案:
apt-get install python
安装python后再执行编译即可解决ERROR: Failed to create toolchain.问题
2.编译中遇到 make: *** [ffbuild/common.mak:60: libavdevice/v4l2.o] Error 1
CC
libavdevice/v4l2.o
libavdevice/v4l2.c:135:9: error: assigning to 'int (*)(int, unsigned long, ...)' from incompatible type '<overloaded function type>'
SET_WRAPPERS();
^~~~~~~~~~~~~~
libavdevice/v4l2.c:121:17: note: expanded from macro 'SET_WRAPPERS'
s->ioctl_f
= prefix ## ioctl;
^
~~~~~
/home/cc/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/bits/ioctl.h:56:5: note: candidate function has type mismatch at 2nd parameter
(expected 'unsigned long' but has 'unsigned int')
int ioctl(int __fd, unsigned __request, ...) __overloadable __enable_if(1, "") __RENAME(ioctl);
^
/home/cc/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/bits/ioctl.h:36:5: note: candidate function has type mismatch at 2nd parameter
(expected 'unsigned long' but has 'int')
int ioctl(int __fd, int __request, ...);
^
1 error generated.
make: *** [ffbuild/common.mak:60: libavdevice/v4l2.o] Error 1
解决方案:
在编译脚本中添加了宏:BIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD
完整代码段:
#!/bin/bash
#在ffmpeg目录下执行该脚本,输出在ffmpeg目录下的android-build 目录里
PREFIX=./android-build
#设置你自己的NDK位置
#NDK_HOME=/Users/lichao/Downloads/ndk21
NDK_HOME=/home/fly/Downloads/ndk21
COMMON_OPTIONS="
--target-os=android
--disable-static
--enable-shared
--enable-small
--disable-programs
--disable-ffmpeg
--disable-ffplay
--disable-ffprobe
--disable-doc
--disable-symver
--disable-asm
"
function build_android {
./configure
--libdir=${PREFIX}/libs/armeabi-v7a
--incdir=${PREFIX}/includes/armeabi-v7a
--pkgconfigdir=${PREFIX}/pkgconfig/armeabi-v7a
--arch=arm
--cpu=armv7-a
--cross-prefix="${NDK_HOME}/bin/arm-linux-androideabi-"
--sysroot="${NDK_HOME}/sysroot/"
--extra-ldexeflags=-pie
--extra-cflags="-Os -fpic -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD"
${COMMON_OPTIONS}
make clean
make -j8 && make install
./configure
--libdir=${PREFIX}/libs/arm64-v8a
--incdir=${PREFIX}/includes/arm64-v8a
--pkgconfigdir=${PREFIX}/pkgconfig/arm64-v8a
--arch=aarch64
--cpu=armv8-a
--cross-prefix="${NDK_HOME}/bin/aarch64-linux-android-"
--sysroot="${NDK_HOME}/sysroot/"
--extra-ldexeflags=-pie
--extra-cflags="-Os -fpic -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD"
${COMMON_OPTIONS}
make clean
make -j8 && make install
./configure
--libdir=${PREFIX}/libs/x86
--incdir=${PREFIX}/includes/x86
--pkgconfigdir=${PREFIX}/pkgconfig/x86
--arch=x86
--cpu=i686
--cross-prefix="${NDK_HOME}/bin/i686-linux-android-"
--sysroot="${NDK_HOME}/sysroot/"
--extra-ldexeflags=-pie
--extra-cflags="-Os -fpic -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD"
${COMMON_OPTIONS}
make clean
make -j8 && make install
./configure
--libdir=${PREFIX}/libs/x86_64
--incdir=${PREFIX}/includes/x86_64
--pkgconfigdir=${PREFIX}/pkgconfig/x86_64
--arch=x86_64
--cpu=x86_64
--cross-prefix="${NDK_HOME}/bin/x86_64-linux-android-"
--sysroot="${NDK_HOME}/sysroot/"
--extra-ldexeflags=-pie
--extra-cflags="-Os -fpic -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD"
${COMMON_OPTIONS}
make clean
make -j8 && make install
};
build_android
这里特别注意:在执行./build_ffmpeg_for_android1.sh的时候会报没有权限
解决方案:给予执行权限就可以
chmod 755 ./build_ffmpeg_for_android1.sh
./build_ffmpeg_for_android1.sh
我的电脑等待20分钟左右 终于编译完成:
root@ubuntu:/home/fly/FFmpeg/ffmpeg# ls
android-build
COPYING.GPLv3
libavfilter
presets
build_ffmpeg_for_android1.sh
COPYING.LGPLv2.1
libavformat
README.md
build_ffmpeg_for_android.sh
COPYING.LGPLv3
libavresample
RELEASE
Changelog
CREDITS
libavutil
RELEASE_NOTES
compat
doc
libpostproc
tests
config.asm
ffbuild
libswresample
tools
config.h
fftools
libswscale
VERSION
configure
INSTALL.md
LICENSE.md
CONTRIBUTING.md
libavcodec
MAINTAINERS
COPYING.GPLv2
libavdevice
Makefile
root@ubuntu:/home/fly/FFmpeg/ffmpeg# cd .android-build
bash: cd: .android-build: No such file or directory
root@ubuntu:/home/fly/FFmpeg/ffmpeg# cd ./android-build
root@ubuntu:/home/fly/FFmpeg/ffmpeg/android-build# ls
includes
libs
pkgconfig
root@ubuntu:/home/fly/FFmpeg/ffmpeg/android-build# cd ./libs
root@ubuntu:/home/fly/FFmpeg/ffmpeg/android-build/libs# ls
armeabi-v7a
root@ubuntu:/home/fly/FFmpeg/ffmpeg/android-build/libs# cd ./armeabi-v7a
root@ubuntu:/home/fly/FFmpeg/ffmpeg/android-build/libs/armeabi-v7a# ls
libavcodec.so
libavfilter.so
libavutil.so
libswscale.so
libavdevice.so
libavformat.so
libswresample.so
最后
以上就是彩色学姐为你收集整理的Ubuntu 编译ffmpeg 踩坑(三)的全部内容,希望文章能够帮你解决Ubuntu 编译ffmpeg 踩坑(三)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复