Ubuntu16.04编译ffmpeg

0x01. downlaod

https://ffmpeg.org/download.html

0x02. 解压

目录在ffmpeg-3.4.2中.

0x03. 配置编译脚本

文件名称随便取. 注意文件中的NDK相关配置修改为自己本机的.

#! /bin/bash
#NDK=D:/Android/sdk/ndk-bundle
NDK=/home/iamcxl369/android/android-ndk-r13b
SYSROOT=$NDK/platforms/android-23/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
CPU=arm
PREFIX=~/Downloads/ffmpeg-3.4.2/ffmpeg-3.4.2/android/arm
ADDI_CFLAGS="-marm"

function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-doc \
--disable-symver \
--enable-small \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-I$SYSROOT/usr/include" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG

make clean
make
make install
}

build_one

注意:我是帮别人编译,这个文件来自windows所以,执行的时候报错了.
vi filename能看到没一行后面有个^M, 把这个符号干掉.

0x04 修改配置文件

emacs configure

替换下面几行配置:

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'

0x05 编译

./ffmpeg-compiling.sh
  • 0x01 错误1:
libavcodec/aaccoder.c:803:25: error: expected identifier or '(' before numeric constant
                     int B0 = 0, B1 = 0;
                         ^
libavcodec/aaccoder.c:865:28: error: lvalue required as left operand of assignment
                         B0 += b1+b2;
                            ^
libavcodec/aaccoder.c:866:25: error: 'B1' undeclared (first use in this function)
                         B1 += b3+b4;

解决办法:
找到这个文件把B0名字修改一下(随便改)

  • 0x02 错误2:
libavcodec/hevc_mvs.c: In function 'derive_spatial_merge_candidates':
libavcodec/hevc_mvs.c:208:15: error: 'y0000000' undeclared (first use in this function)
             ((y ## v) >> s->ps.sps->log2_min_pu_size))
               ^
libavcodec/hevc_mvs.c:204:14: note: in definition of macro 'TAB_MVF'
     tab_mvf[(y) * min_pu_width + x]
              ^

解决办法:
在自己本机的ndk目录中找到asm/termbits.h或asm-generic/termbits.h把#define B0 #undef了.

0x06 make

make clean
make
make install

然后就在.sh中配置的目录下生成了目标文件.
~/Downloads/ffmpeg-3.4.2/ffmpeg-3.4.2/android/arm

B0宏
ffmpeg开发之旅(5):详解ffmpeg编译与在Android平台上的移植

你可能感兴趣的:(手机软件开发笔记)