Windows系统下编译FFmpeg for Android(支持x264)
接上一篇:https://www.cnblogs.com/zuoao123/p/10253690.html 一、编译x2641、下载并解压x264下载地址: 下载最新版本,解压后得到x264-snapshot-20190111-2245文件夹。 2、修改configure文件将configure文件中的 if cc_check "stdio.h" "" "fseeko(stdin,0);" ; then define fseek fseeko define ftell ftello elif cc_check "stdio.h" "" "fseeko64(stdin,0);" ; then define fseek fseeko64 define ftell ftello64 elif cc_check "stdio.h" "" "_fseeki64(stdin,0);" ; then define fseek _fseeki64 define ftell _ftelli64 fi 修改为 if cc_check "stdio.h" "" "fseeko(stdin,0);" ; then define fseek fseek define ftell ftell elif cc_check "stdio.h" "" "fseeko64(stdin,0);" ; then define fseek fseek define ftell ftell elif cc_check "stdio.h" "" "_fseeki64(stdin,0);" ; then define fseek _fseek define ftell _ftell fi 否则在编译FFmpeg的时候会报以下错误: ERROR:libx264 not found 查看FFmpeg的config.log,具体原因是 ../android-lib/lib/libx264.a(encoder-8.o):encoder.c:function encoder_frame_end.part.8: error: undefined reference to ‘fseeko64‘ ../android-lib/lib/libx264.a(opencl-8.o):opencl.c:function x264_8_opencl_lookahead_init: error: undefined reference to ‘fseeko64‘ ../android-lib/lib/libx264.a(opencl-8.o):opencl.c:function x264_8_opencl_lookahead_init: error: undefined reference to ‘ftello64‘ ../android-lib/lib/libx264.a(encoder-10.o):encoder.c:function encoder_frame_end.part.9: error: undefined reference to ‘fseeko64‘ ../android-lib/lib/libx264.a(base.o):base.c:function x264_slurp_file: error: undefined reference to ‘fseeko64‘ ../android-lib/lib/libx264.a(base.o):base.c:function x264_slurp_file: error: undefined reference to ‘ftello64‘ collect2.exe: error: ld returned 1 exit status ERROR: libx264 not found 因此在这里修改x264的configure文件,杜绝编译FFmpeg不通过。(暂未发现其他解决方法) 3、在x264目录下新建build_android.sh脚本文件文件内容如下: #!/bin/bash # 设置编译中临时文件目录,不然会报错 unable to create temporary file export TMPDIR=./temp mkdir $TMPDIR # NDK的路径,根据实际安装位置设置 NDK=D:/Work_Files/android-ndk-r16b # 编译针对的平台,这里选择最低支持android-23,arm架构,生成的so库是放在libs/armeabi文件夹下的,若针对x86架构,要选择arch-x86 SYSROOT=$NDK/platforms/android-23/arch-arm # 工具链的路径,arm-linux-androideabi-4.9与上面设置的PLATFORM对应,4.9为工具的版本号 TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 ARCH=armv7-a PREFIX=./output/$ARCH EXTRA_CFLAGS="-isystem $NDK/sysroot/usr/include -isystem $NDK/sysroot/usr/include/arm-linux-androideabi" function build_one { ./configure --prefix=$PREFIX --extra-cflags="$EXTRA_CFLAGS" --enable-static --host=arm-linux --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- --sysroot=$SYSROOT --disable-asm --enable-pic --disable-cli } build_one 4、执行build_android.sh脚本文件进行配置./build_android.sh 5、执行make、make install命令进行编译安装最后在D:Work_Filesx264-snapshot-20190111-2245outputarmv7-a目录下得到需要的头文件和库文件。 二、编译FFmpeg1、修改FFmpeg的build_android.sh脚本文件文件内容如下: #!/bin/bash # 设置编译中临时文件目录,不然会报错 unable to create temporary file export TMPDIR=./temp mkdir $TMPDIR # NDK的路径,根据实际安装位置设置 NDK=D:/Work_Files/android-ndk-r16b # 编译针对的平台,这里选择最低支持android-23,arm架构,生成的so库是放在libs/armeabi文件夹下的,若针对x86架构,要选择arch-x86 SYSROOT=$NDK/platforms/android-23/arch-arm # 工具链的路径,arm-linux-androideabi-4.9与上面设置的PLATFORM对应,4.9为工具的版本号 TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 ARCH=armv7-a PREFIX=./output/$ARCH EXTRA_CFLAGS="-I D:/Work_Files/x264-snapshot-20190111-2245/output/armv7-a/include -fdata-sections -ffunction-sections -fstack-protector-strong -ffast-math -fstrict-aliasing -march=$ARCH -D__ANDROID_API__=23 -isystem $NDK/sysroot/usr/include -isystem $NDK/sysroot/usr/include/arm-linux-androideabi" EXTRA_LDFLAGS="-L D:/Work_Files/x264-snapshot-20190111-2245/output/armv7-a/lib -Wl,--gc-sections -Wl,-z,relro -Wl,now" function build_one { ./configure --prefix=$PREFIX --enable-static --disable-shared --enable-small --enable-runtime-cpudetect --disable-programs --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-doc --enable-pthreads --disable-decoders --enable-decoder=h264 --disable-encoders --disable-hwaccels --disable-parsers --enable-parser=h264 --disable-demuxers --disable-muxers --disable-protocols --disable-filters --disable-bsfs --disable-indevs --disable-outdevs --disable-v4l2_m2m --enable-jni --enable-gpl --enable-libx264 --arch=$ARCH --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- --enable-cross-compile --sysroot=$SYSROOT --target-os=android --disable-symver --enable-asm --enable-neon --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" $ADDITIONAL_CONFIGURE_FLAG } build_one 2、执行build_android.sh脚本文件进行配置./build_android.sh 3、执行make、make install命令进行编译安装最后在D:Work_Filesffmpeg-for-androidffmpeg-3.4.5outputarmv7-a目录下得到需要的头文件和库文件 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |