ijkplayer作为一款基于ffmpeg在移动端比较流行的播放器,并没有集成编码器。如果使用ffmpeg且需要音视频编码功能的话就需要自己手动集成。
编译支持x264编码器的流程主要参考了
ijkplayer支持x264编译 - 简书
原理与ijkplayer编译支持openssl的流程类似。
1 下载x264源码
在ijkplayer源码根目录下新建init-android-x264.sh 内容如下:
IJK_x264_UPSTREAM=http://git.videolan.org/git/x264.git
IJK_x264_FORK=http://git.videolan.org/git/x264.gitIJK_x264_LOCAL_REPO=extra/x264set -e
TOOLS=toolsecho "== pull x264 base =="
sh $TOOLS/pull-repo-base.sh $IJK_x264_UPSTREAM $IJK_x264_LOCAL_REPOfunction pull_fork()
{echo "== pull x264 fork $1 =="sh $TOOLS/pull-repo-ref.sh $IJK_x264_FORK android/contrib/x264-$1 ${IJK_x264_LOCAL_REPO}
}pull_fork "armv5"
pull_fork "armv7a"
pull_fork "arm64"
pull_fork "x86"
pull_fork "x86_64"
执行
./init-android-x264.sh
同下载ffmpeg源码一样,会在extra下生成一个x264源码文件夹,以及在android/contrib下生成5个x264各个架构的源码文件夹。
2 编译x264
增加编译脚本,在android/contrib下新建compile-x264.sh ,在android/contrib/tools 下新建do-compile-x264.sh
compile-x264.sh脚本内容如下:
UNI_BUILD_ROOT=`pwd`
FF_TARGET=$1
set -e
set +xFF_ACT_ARCHS_32="armv5 armv7a x86"
FF_ACT_ARCHS_64="armv5 armv7a arm64 x86 x86_64"
FF_ACT_ARCHS_ALL=$FF_ACT_ARCHS_64echo_archs() {echo "===================="echo "[*] check archs"echo "===================="echo "FF_ALL_ARCHS = $FF_ACT_ARCHS_ALL"echo "FF_ACT_ARCHS = $*"echo ""
}echo_usage() {echo "Usage:"echo " compile-x264.sh armv5|armv7a|arm64|x86|x86_64"echo " compile-x264.sh all|all32"echo " compile-x264.sh all64"echo " compile-x264.sh clean"echo " compile-x264.sh check"exit 1
}echo_nextstep_help() {#----------echo ""echo "--------------------"echo "[*] Finished"echo "--------------------"echo "# to continue to build ffmpeg, run script below,"echo "sh compile-ffmpeg.sh "echo "# to continue to build ijkplayer, run script below,"echo "sh compile-ijk.sh "
}#----------
case "$FF_TARGET" in"")echo_archs armv7ash tools/do-compile-x264.sh armv7a;;armv5|armv7a|arm64|x86|x86_64)echo_archs $FF_TARGETsh tools/do-compile-x264.sh $FF_TARGETecho_nextstep_help;;all32)echo_archs $FF_ACT_ARCHS_32for ARCH in $FF_ACT_ARCHS_32dosh tools/do-compile-x264.sh $ARCHdoneecho_nextstep_help;;all|all64)echo_archs $FF_ACT_ARCHS_64for ARCH in $FF_ACT_ARCHS_64dosh tools/do-compile-x264.sh $ARCHdoneecho_nextstep_help;;clean)echo_archs FF_ACT_ARCHS_64for ARCH in $FF_ACT_ARCHS_ALLdoif [ -d x264-$ARCH ]; thencd x264-$ARCH && git clean -xdf && cd -fidonerm -rf ./build/x264-*;;check)echo_archs FF_ACT_ARCHS_ALL;;*)echo_usageexit 1;;
esac
do-compile-x264.sh脚本内容如下:
set -eif [ -z "$ANDROID_NDK" ]; thenecho "You must define ANDROID_NDK before starting."echo "They must point to your NDK directories.\n"exit 1
fi#--------------------
# common defines
FF_ARCH=$1
if [ -z "$FF_ARCH" ]; thenecho "You must specific an architecture 'arm, armv7a, x86, ...'.\n"exit 1
fiFF_BUILD_ROOT=`pwd`
FF_ANDROID_PLATFORM=android-9FF_BUILD_NAME=
FF_SOURCE=
FF_CROSS_PREFIX=FF_CFG_FLAGS=
FF_PLATFORM_CFG_FLAGS=FF_EXTRA_CFLAGS=
FF_EXTRA_LDFLAGS=#--------------------
echo ""
echo "--------------------"
echo "[*] make NDK standalone toolchain"
echo "--------------------"
. ./tools/do-detect-env.sh
FF_MAKE_TOOLCHAIN_FLAGS=$IJK_MAKE_TOOLCHAIN_FLAGS
FF_MAKE_FLAGS=$IJK_MAKE_FLAG
FF_GCC_VER=$IJK_GCC_VER
FF_GCC_64_VER=$IJK_GCC_64_VER#----- armv7a begin -----
if [ "$FF_ARCH" = "armv7a" ]; thenecho "gdebug x264-armv7a.............."FF_BUILD_NAME=x264-armv7aFF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=arm-linux-androideabiFF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_VER}FF_PLATFORM_CFG_FLAGS="android-armv7"elif [ "$FF_ARCH" = "armv5" ]; thenFF_BUILD_NAME=x264-armv5FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=arm-linux-androideabiFF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_VER}FF_PLATFORM_CFG_FLAGS="android"elif [ "$FF_ARCH" = "x86" ]; thenFF_BUILD_NAME=x264-x86FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=i686-linux-androidFF_TOOLCHAIN_NAME=x86-${FF_GCC_VER}FF_PLATFORM_CFG_FLAGS="android-x86"elif [ "$FF_ARCH" = "x86_64" ]; thenFF_ANDROID_PLATFORM=android-21FF_BUILD_NAME=x264-x86_64FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=x86_64-linux-androidFF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_64_VER}FF_PLATFORM_CFG_FLAGS="linux-x86_64"elif [ "$FF_ARCH" = "arm64" ]; thenFF_ANDROID_PLATFORM=android-21FF_BUILD_NAME=x264-arm64FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=aarch64-linux-androidFF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_64_VER}FF_PLATFORM_CFG_FLAGS="linux-aarch64"elseecho "unknown architecture $FF_ARCH";exit 1
fiFF_TOOLCHAIN_PATH=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/toolchainFF_SYSROOT=$FF_TOOLCHAIN_PATH/sysroot
FF_PREFIX=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/outputmkdir -p $FF_PREFIX
mkdir -p $FF_SYSROOT#--------------------
echo ""
echo "--------------------"
echo "[*] make NDK standalone toolchain"
echo "--------------------"
. ./tools/do-detect-env.sh
FF_MAKE_TOOLCHAIN_FLAGS=$IJK_MAKE_TOOLCHAIN_FLAGS
FF_MAKE_FLAGS=$IJK_MAKE_FLAGFF_MAKE_TOOLCHAIN_FLAGS="$FF_MAKE_TOOLCHAIN_FLAGS --install-dir=$FF_TOOLCHAIN_PATH"
FF_TOOLCHAIN_TOUCH="$FF_TOOLCHAIN_PATH/touch"
if [ ! -f "$FF_TOOLCHAIN_TOUCH" ]; then$ANDROID_NDK/build/tools/make-standalone-toolchain.sh \$FF_MAKE_TOOLCHAIN_FLAGS \--platform=$FF_ANDROID_PLATFORM \--toolchain=$FF_TOOLCHAIN_NAMEtouch $FF_TOOLCHAIN_TOUCH;
fi#--------------------
echo ""
echo "--------------------"
echo "[*] check x264 env"
echo "--------------------"
export PATH=$FF_TOOLCHAIN_PATH/bin:$PATHexport COMMON_FF_CFG_FLAGS=FF_CFG_FLAGS="$FF_CFG_FLAGS $COMMON_FF_CFG_FLAGS"#--------------------
# Standard options:
echo "FF_PREFIX = $FF_PREFIX"
FF_CFG_FLAGS="$FF_CFG_FLAGS --prefix=$FF_PREFIX"
FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-static --disable-shared"
FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-pic --enable-strip --disable-asm --disable-cli"
#FF_CFG_FLAGS="$FF_CFG_FLAGS --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi-"
FF_CFG_FLAGS="$FF_CFG_FLAGS --cross-prefix=${FF_CROSS_PREFIX}-"
FF_CFG_FLAGS="$FF_CFG_FLAGS --host=arm-linux"
FF_CFG_FLAGS="$FF_CFG_FLAGS --sysroot=$FF_SYSROOT"#FF_CFG_FLAGS="$FF_CFG_FLAGS --cross-prefix=${FF_CROSS_PREFIX}-"
#FF_CFG_FLAGS="$FF_CFG_FLAGS $FF_PLATFORM_CFG_FLAGS"#--------------------
echo ""
echo "--------------------"
echo "[*] configurate x264"
echo "--------------------"
cd $FF_SOURCE && chmod +w configure
#if [ -f "./Makefile" ]; then
# echo 'reuse configure'
#elseecho "./configure $FF_CFG_FLAGS"./configure $FF_CFG_FLAGS
# --extra-cflags="$FF_CFLAGS $FF_EXTRA_CFLAGS" \
# --extra-ldflags="$FF_EXTRA_LDFLAGS"
#fi#--------------------
echo ""
echo "--------------------"
echo "[*] compile x264"
echo "--------------------"
make depend
echo "make $FF_MAKE_FLAGS"
make $FF_MAKE_FLAGS
make install#--------------------
echo ""
echo "--------------------"
echo "[*] link x264"
echo "--------------------"
同编译openssl的流程类似。
在mac终端定位到android/contrib目录。
执行
./compile-x264.sh clean
再执行
./compile-x264.sh armv7a
这里只编译支持armv7a架构,若要支持所有架构,将armv7a改为all。
执行成功后在android/contrib/build目录下会生成一个x264-armv7a的目录。
3. 与ijkplayer使用的ffmpeg交叉编译脚本修改
修改androdi/contrib/tools目录下的do-compile-ffmpeg.sh脚本文件,内容如下:
#! /usr/bin/env bash
#
# Copyright (C) 2013-2014 Zhang Rui <bbcallen@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
## This script is based on projects below
# https://github.com/yixia/FFmpeg-Android
# http://git.videolan.org/?p=vlc-ports/android.git;a=summary#--------------------
echo "===================="
echo "[*] check env $1"
echo "===================="
set -e#--------------------
# common defines
FF_ARCH=$1
FF_BUILD_OPT=$2
echo "FF_ARCH=$FF_ARCH"
echo "FF_BUILD_OPT=$FF_BUILD_OPT"
if [ -z "$FF_ARCH" ]; thenecho "You must specific an architecture 'arm, armv7a, x86, ...'."echo ""exit 1
fiFF_BUILD_ROOT=`pwd`
FF_ANDROID_PLATFORM=android-9FF_BUILD_NAME=
FF_SOURCE=
FF_CROSS_PREFIX=
FF_DEP_OPENSSL_INC=
FF_DEP_OPENSSL_LIB=
FF_DEP_X264_INC=
FF_DEP_X264_LIB=
FF_DEP_LIBSOXR_INC=
FF_DEP_LIBSOXR_LIB=FF_CFG_FLAGS=FF_EXTRA_CFLAGS=
FF_EXTRA_LDFLAGS=
FF_DEP_LIBS=FF_MODULE_DIRS="compat libavcodec libavfilter libavformat libavutil libswresample libswscale"
FF_ASSEMBLER_SUB_DIRS=#--------------------
echo ""
echo "--------------------"
echo "[*] make NDK standalone toolchain"
echo "--------------------"
. ./tools/do-detect-env.sh
FF_MAKE_TOOLCHAIN_FLAGS=$IJK_MAKE_TOOLCHAIN_FLAGS
FF_MAKE_FLAGS=$IJK_MAKE_FLAG
FF_GCC_VER=$IJK_GCC_VER
FF_GCC_64_VER=$IJK_GCC_64_VER#----- armv7a begin -----
if [ "$FF_ARCH" = "armv7a" ]; thenFF_BUILD_NAME=ffmpeg-armv7aFF_BUILD_NAME_OPENSSL=openssl-armv7aFF_BUILD_NAME_X264=x264-armv7aFF_BUILD_NAME_LIBSOXR=libsoxr-armv7aFF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=arm-linux-androideabiFF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_VER}FF_CFG_FLAGS="$FF_CFG_FLAGS --arch=arm --cpu=cortex-a8"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-neon"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-thumb"FF_EXTRA_CFLAGS="$FF_EXTRA_CFLAGS -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb"FF_EXTRA_LDFLAGS="$FF_EXTRA_LDFLAGS -Wl,--fix-cortex-a8"FF_ASSEMBLER_SUB_DIRS="arm"elif [ "$FF_ARCH" = "armv5" ]; thenFF_BUILD_NAME=ffmpeg-armv5FF_BUILD_NAME_OPENSSL=openssl-armv5FF_BUILD_NAME_X264=x264-armv5FF_BUILD_NAME_LIBSOXR=libsoxr-armv5FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=arm-linux-androideabiFF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_VER}FF_CFG_FLAGS="$FF_CFG_FLAGS --arch=arm"FF_EXTRA_CFLAGS="$FF_EXTRA_CFLAGS -march=armv5te -mtune=arm9tdmi -msoft-float"FF_EXTRA_LDFLAGS="$FF_EXTRA_LDFLAGS"FF_ASSEMBLER_SUB_DIRS="arm"elif [ "$FF_ARCH" = "x86" ]; thenFF_BUILD_NAME=ffmpeg-x86FF_BUILD_NAME_OPENSSL=openssl-x86FF_BUILD_NAME_X264=x264-x86FF_BUILD_NAME_LIBSOXR=libsoxr-x86FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=i686-linux-androidFF_TOOLCHAIN_NAME=x86-${FF_GCC_VER}FF_CFG_FLAGS="$FF_CFG_FLAGS --arch=x86 --cpu=i686 --enable-yasm"FF_EXTRA_CFLAGS="$FF_EXTRA_CFLAGS -march=atom -msse3 -ffast-math -mfpmath=sse"FF_EXTRA_LDFLAGS="$FF_EXTRA_LDFLAGS"FF_ASSEMBLER_SUB_DIRS="x86"elif [ "$FF_ARCH" = "x86_64" ]; thenFF_ANDROID_PLATFORM=android-21FF_BUILD_NAME=ffmpeg-x86_64FF_BUILD_NAME_OPENSSL=openssl-x86_64FF_BUILD_NAME_X264=x264-x86_64FF_BUILD_NAME_LIBSOXR=libsoxr-x86_64FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=x86_64-linux-androidFF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_64_VER}FF_CFG_FLAGS="$FF_CFG_FLAGS --arch=x86_64 --enable-yasm"FF_EXTRA_CFLAGS="$FF_EXTRA_CFLAGS"FF_EXTRA_LDFLAGS="$FF_EXTRA_LDFLAGS"FF_ASSEMBLER_SUB_DIRS="x86"elif [ "$FF_ARCH" = "arm64" ]; thenFF_ANDROID_PLATFORM=android-21FF_BUILD_NAME=ffmpeg-arm64FF_BUILD_NAME_OPENSSL=openssl-arm64FF_BUILD_NAME_X264=x264-arm64FF_BUILD_NAME_LIBSOXR=libsoxr-arm64FF_SOURCE=$FF_BUILD_ROOT/$FF_BUILD_NAMEFF_CROSS_PREFIX=aarch64-linux-androidFF_TOOLCHAIN_NAME=${FF_CROSS_PREFIX}-${FF_GCC_64_VER}FF_CFG_FLAGS="$FF_CFG_FLAGS --arch=aarch64 --enable-yasm"FF_EXTRA_CFLAGS="$FF_EXTRA_CFLAGS"FF_EXTRA_LDFLAGS="$FF_EXTRA_LDFLAGS"FF_ASSEMBLER_SUB_DIRS="aarch64 neon"elseecho "unknown architecture $FF_ARCH";exit 1
fiif [ ! -d $FF_SOURCE ]; thenecho ""echo "!! ERROR"echo "!! Can not find FFmpeg directory for $FF_BUILD_NAME"echo "!! Run 'sh init-android.sh' first"echo ""exit 1
fiFF_TOOLCHAIN_PATH=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/toolchain
FF_MAKE_TOOLCHAIN_FLAGS="$FF_MAKE_TOOLCHAIN_FLAGS --install-dir=$FF_TOOLCHAIN_PATH"FF_SYSROOT=$FF_TOOLCHAIN_PATH/sysroot
FF_PREFIX=$FF_BUILD_ROOT/build/$FF_BUILD_NAME/output
FF_DEP_OPENSSL_INC=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_OPENSSL/output/include
FF_DEP_OPENSSL_LIB=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_OPENSSL/output/lib
FF_DEP_X264_INC=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_X264/output/include
FF_DEP_X264_LIB=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_X264/output/lib
FF_DEP_LIBSOXR_INC=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_LIBSOXR/output/include
FF_DEP_LIBSOXR_LIB=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_LIBSOXR/output/libcase "$UNAME_S" inCYGWIN_NT-*)FF_SYSROOT="$(cygpath -am $FF_SYSROOT)"FF_PREFIX="$(cygpath -am $FF_PREFIX)";;
esacmkdir -p $FF_PREFIX
# mkdir -p $FF_SYSROOTFF_TOOLCHAIN_TOUCH="$FF_TOOLCHAIN_PATH/touch"
if [ ! -f "$FF_TOOLCHAIN_TOUCH" ]; then$ANDROID_NDK/build/tools/make-standalone-toolchain.sh \$FF_MAKE_TOOLCHAIN_FLAGS \--platform=$FF_ANDROID_PLATFORM \--toolchain=$FF_TOOLCHAIN_NAMEtouch $FF_TOOLCHAIN_TOUCH;
fi#--------------------
echo ""
echo "--------------------"
echo "[*] check ffmpeg env"
echo "--------------------"
export PATH=$FF_TOOLCHAIN_PATH/bin/:$PATH
#export CC="ccache ${FF_CROSS_PREFIX}-gcc"
export CC="${FF_CROSS_PREFIX}-gcc"
export LD=${FF_CROSS_PREFIX}-ld
export AR=${FF_CROSS_PREFIX}-ar
export STRIP=${FF_CROSS_PREFIX}-stripFF_CFLAGS="-O3 -Wall -pipe \-std=c99 \-ffast-math \-fstrict-aliasing -Werror=strict-aliasing \-Wno-psabi -Wa,--noexecstack \-DANDROID -DNDEBUG"# cause av_strlcpy crash with gcc4.7, gcc4.8
# -fmodulo-sched -fmodulo-sched-allow-regmoves# --enable-thumb is OK
#FF_CFLAGS="$FF_CFLAGS -mthumb"# not necessary
#FF_CFLAGS="$FF_CFLAGS -finline-limit=300"export COMMON_FF_CFG_FLAGS=
. $FF_BUILD_ROOT/../../config/module.sh#--------------------
# with openssl
if [ -f "${FF_DEP_OPENSSL_LIB}/libssl.a" ]; thenecho "OpenSSL detected"
# FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-nonfree"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-openssl"FF_CFLAGS="$FF_CFLAGS -I${FF_DEP_OPENSSL_INC}"FF_DEP_LIBS="$FF_DEP_LIBS -L${FF_DEP_OPENSSL_LIB} -lssl -lcrypto"
fi# with libx264
if [ -f "${FF_DEP_X264_LIB}/libx264.a" ]; thenecho "libx264 detected"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-libx264"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-encoder=libx264"FF_CFLAGS="$FF_CFLAGS -I${FF_DEP_X264_INC}"FF_DEP_LIBS="$FF_DEP_LIBS -L${FF_DEP_X264_LIB} -lx264"export PKG_CONFIG_PATH="$FF_DEP_X264_LIB/pkgconfig":$FF_PREFIX/lib/pkgconfigecho $PKG_CONFIG_PATH
fiif [ -f "${FF_DEP_LIBSOXR_LIB}/libsoxr.a" ]; thenecho "libsoxr detected"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-libsoxr"FF_CFLAGS="$FF_CFLAGS -I${FF_DEP_LIBSOXR_INC}"FF_DEP_LIBS="$FF_DEP_LIBS -L${FF_DEP_LIBSOXR_LIB} -lsoxr"
fiFF_CFG_FLAGS="$FF_CFG_FLAGS $COMMON_FF_CFG_FLAGS"#--------------------
# Standard options:
FF_CFG_FLAGS="$FF_CFG_FLAGS --prefix=$FF_PREFIX"# Advanced options (experts only):
FF_CFG_FLAGS="$FF_CFG_FLAGS --cross-prefix=${FF_CROSS_PREFIX}-"
FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-cross-compile"
FF_CFG_FLAGS="$FF_CFG_FLAGS --target-os=linux"
FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-pic"
# FF_CFG_FLAGS="$FF_CFG_FLAGS --disable-symver"if [ "$FF_ARCH" = "x86" ]; thenFF_CFG_FLAGS="$FF_CFG_FLAGS --disable-asm"
else# Optimization options (experts only):FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-asm"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-inline-asm"
ficase "$FF_BUILD_OPT" indebug)FF_CFG_FLAGS="$FF_CFG_FLAGS --disable-optimizations"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-debug"FF_CFG_FLAGS="$FF_CFG_FLAGS --disable-small";;*)FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-optimizations"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-debug"FF_CFG_FLAGS="$FF_CFG_FLAGS --enable-small";;
esac#--------------------
echo ""
echo "--------------------"
echo "[*] configurate ffmpeg"
echo "--------------------"
cd $FF_SOURCE
if [ -f "./config.h" ]; thenecho 'reuse configure'
elsewhich $CC./configure $FF_CFG_FLAGS \--extra-cflags="$FF_CFLAGS $FF_EXTRA_CFLAGS" \--extra-ldflags="$FF_DEP_LIBS $FF_EXTRA_LDFLAGS"make clean
fi#--------------------
echo ""
echo "--------------------"
echo "[*] compile ffmpeg"
echo "--------------------"
cp config.* $FF_PREFIX
make $FF_MAKE_FLAGS > /dev/null
make install
mkdir -p $FF_PREFIX/include/libffmpeg
cp -f config.h $FF_PREFIX/include/libffmpeg/config.h#--------------------
echo ""
echo "--------------------"
echo "[*] link ffmpeg"
echo "--------------------"
echo $FF_EXTRA_LDFLAGSFF_C_OBJ_FILES=
FF_ASM_OBJ_FILES=
for MODULE_DIR in $FF_MODULE_DIRS
doC_OBJ_FILES="$MODULE_DIR/*.o"if ls $C_OBJ_FILES 1> /dev/null 2>&1; thenecho "link $MODULE_DIR/*.o"FF_C_OBJ_FILES="$FF_C_OBJ_FILES $C_OBJ_FILES"fifor ASM_SUB_DIR in $FF_ASSEMBLER_SUB_DIRSdoASM_OBJ_FILES="$MODULE_DIR/$ASM_SUB_DIR/*.o"if ls $ASM_OBJ_FILES 1> /dev/null 2>&1; thenecho "link $MODULE_DIR/$ASM_SUB_DIR/*.o"FF_ASM_OBJ_FILES="$FF_ASM_OBJ_FILES $ASM_OBJ_FILES"fidone
done$CC -lm -lz -shared --sysroot=$FF_SYSROOT -Wl,--no-undefined -Wl,-z,noexecstack $FF_EXTRA_LDFLAGS \-Wl,-soname,libijkffmpeg.so \$FF_C_OBJ_FILES \$FF_ASM_OBJ_FILES \$FF_DEP_LIBS \-o $FF_PREFIX/libijkffmpeg.somysedi() {f=$1exp=$2n=`basename $f`cp $f /tmp/$nsed $exp /tmp/$n > $frm /tmp/$n
}echo ""
echo "--------------------"
echo "[*] create files for shared ffmpeg"
echo "--------------------"
rm -rf $FF_PREFIX/shared
mkdir -p $FF_PREFIX/shared/lib/pkgconfig
ln -s $FF_PREFIX/include $FF_PREFIX/shared/include
ln -s $FF_PREFIX/libijkffmpeg.so $FF_PREFIX/shared/lib/libijkffmpeg.so
cp $FF_PREFIX/lib/pkgconfig/*.pc $FF_PREFIX/shared/lib/pkgconfig
for f in $FF_PREFIX/lib/pkgconfig/*.pc; do# in case empty dirif [ ! -f $f ]; thencontinueficp $f $FF_PREFIX/shared/lib/pkgconfigf=$FF_PREFIX/shared/lib/pkgconfig/`basename $f`# OSX sed doesn't have in-place(-i)mysedi $f 's/\/output/\/output\/shared/g'mysedi $f 's/-lavcodec/-lijkffmpeg/g'mysedi $f 's/-lavfilter/-lijkffmpeg/g'mysedi $f 's/-lavformat/-lijkffmpeg/g'mysedi $f 's/-lavutil/-lijkffmpeg/g'mysedi $f 's/-lswresample/-lijkffmpeg/g'mysedi $f 's/-lswscale/-lijkffmpeg/g'
done
脚本中涉及x264的地方一定要改全,我因为有个地方没改全,导致编译的时候找不到x264。
compile-ffmpeg.sh文件不需要修改。
4 修改编译配置,开启编码器
进入config目录,修改编译配置脚本
这里使用的是module-default.sh。
完整脚本内容如下:
#! /usr/bin/env bash#--------------------
# Standard options:
export COMMON_FF_CFG_FLAGS=
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --prefix=PREFIX"# Licensing options:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-gpl"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-libx264"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoder=libx264"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-version3"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-nonfree"# Configuration options:
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-static"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-shared"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-small"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-runtime-cpudetect"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-gray"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-swscale-alpha"# Program options:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-programs"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ffmpeg"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ffplay"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ffprobe"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ffserver"# Documentation options:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-doc"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-htmlpages"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-manpages"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-podpages"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-txtpages"# Component options:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-avdevice"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-avcodec"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-avformat"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-avutil"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-swresample"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-swscale"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-postproc"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-avfilter"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-avresample"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-pthreads"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-w32threads"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-os2threads"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-network"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-dct"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-dwt"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-lsp"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-lzo"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-mdct"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-rdft"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-fft"# Hardware accelerators:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-dxva2"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-vaapi"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-vda"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-vdpau"# Individual component options:
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-everything"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoders"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-decoders"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-hwaccels"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-muxers"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-muxer=mp4"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-muxer=mpegts"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-muxer=flv"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-demuxers"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-parsers"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-bsfs"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-protocols"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-devices"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-filters"# External library support:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-iconv"
# ...export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-protocol=async"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-linux-perf"
# Advanced options (experts only):
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --cross-prefix=${FF_CROSS_PREFIX}-"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-cross-compile"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --sysroot=PATH"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --sysinclude=PATH"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --target-os=TAGET_OS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --target-exec=CMD"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --target-path=DIR"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --toolchain=NAME"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --nm=NM"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --ar=AR"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --as=AS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --yasmexe=EXE"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --cc=CC"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --cxx=CXX"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --dep-cc=DEPCC"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --ld=LD"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --host-cc=HOSTCC"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --host-cflags=HCFLAGS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --host-cppflags=HCPPFLAGS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --host-ld=HOSTLD"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --host-ldflags=HLDFLAGS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --host-libs=HLIBS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --host-os=OS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --extra-cflags=ECFLAGS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --extra-cxxflags=ECFLAGS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --extra-ldflags=ELDFLAGS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --extra-libs=ELIBS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --extra-version=STRING"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --optflags=OPTFLAGS"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --build-suffix=SUFFIX"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --malloc-prefix=PREFIX"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --progs-suffix=SUFFIX"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --arch=ARCH"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --cpu=CPU"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-pic"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-sram"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-thumb"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-symver"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-hardcoded-tables"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-safe-bitstream-reader"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-memalign-hack"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-lto"# Optimization options (experts only):
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-asm"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-altivec"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-amd3dnow"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-amd3dnowext"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-mmx"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-mmxext"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-sse"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-sse2"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-sse3"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ssse3"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-sse4"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-sse42"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-avx"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-fma4"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-armv5te"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-armv6"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-armv6t2"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-vfp"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-neon"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-vis"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-inline-asm"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-yasm"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-mips32r2"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-mipsdspr1"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-mipsdspr2"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-mipsfpu"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-fast-unaligned"# Developer options (useful when working on FFmpeg itself):
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-coverage"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-debug"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-debug=LEVEL"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-optimizations"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-extra-warnings"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-stripping"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --assert-level=level"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-memory-poisoning"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --valgrind=VALGRIND"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-ftrapv"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --samples=PATH"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-xmm-clobber-test"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-random"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-random"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-random=LIST"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-random=LIST"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --random-seed=VALUE"
实际上脚本中比较关键的几个修改的地方如下:
# Licensing options:
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-gpl"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-libx264"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoder=libx264"
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-version3"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-nonfree"# Individual component options:
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-everything"
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoders"
主要是要开启编码器,并开启GPL,需要注意的是GPL开源协议是更严格的一种开源协议。GPL是代码的开源/免费使用和引用/修改/衍生代码的开源/免费使用,但不允许修改后和衍生的代码做为闭源的商业软件发布和销售。
执行
rm module.sh
ln -s module-default.sh module.sh
5 编译生成libijkffmpeg.so
进入android/contrib目录
执行
./compile-ffmpeg.sh clean
然后执行
./compile-ffmpeg.sh armv7a
然后顺利的话就会生成带有编码器的libijkffmpeg.so。
6 问题
^
libavcodec/libx264.c: In function 'X264_frame':
libavcodec/libx264.c:282:9: error: 'x264_bit_depth' undeclared (first use in this function)if (x264_bit_depth > 8)^
libavcodec/libx264.c:282:9: note: each undeclared identifier is reported only once for each function it appears in
libavcodec/libx264.c: In function 'X264_init_static':
libavcodec/libx264.c:892:9: error: 'x264_bit_depth' undeclared (first use in this function)if (x264_bit_depth == 8)^
make: *** [libavcodec/libx264.o] Error 1
报x264_bit_depth声明未找到的问题,导致编译失败。
http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=2a111c99a60fdf4fe5eea2b073901630190c6c93
根据上面这篇文章里讲的,应该是x264某个版本之后哪位大神将原来的x264_bit_depth改成了大写的X264_BIT_DEPTH。所以一个思路找到这个定义修改之前的某个版本的x264重新clone下来进行编译。后来发现还有另外一种方法更为简便,就是直接修改libx264.c文件,将此文件中的所有x264_bit_depth直接替换为X264_BIT_DEPTH,然后重新进行libijkffmpeg.so的编译。你没看错就是这么简单、粗暴!但是要注意的是修改的libx264.c的文件路径,不能修改错了。
文件路径在android/contrib/ffmpeg-armv7a/libavcodec目录下,我只编译armv7a架构的so,所以只改ffmpeg-armv7a目录下的文件。
然后重新执行一遍libijkffmpeg.so的编译过程,编译出来的so就支持视频编码了。