Porting FFmpeg on android sdk

Background:
I recently wanted to port FFmpeg to the Android SDK for debugging on the device or writing small code myself, based on Android 4.4.

1. Download FFmpeg source code

There is nothing to say in this step, paste the official website path http://ffmpeg.org/download.html , from here you can download the latest FFmpeg.

2. Compile on the Android platform

Move it to the Android source directory. The compilation of FFmpeg is divided into 3 steps:
1) Execute the ./configure script under the FFmpeg source code and bring the required parameters.
There are still many compilation options, you can refer to this article:
https://blog.csdn.net/momo0853/article/details/78043903#%E6%A0%87%E5%87%86%E9%80%89%E9 %A1%B9standard-options
2) make; make install This will output the compiled things to the specified directory

For convenience, thank you for a compilation script, mainly to compile some static libraries for other programs to call. I mainly configure the following options here:

1)–sysroot=$SYSROOT

The header files and library locations of the cross toolchain are specified, for example, the Android 32-bit location $ndk_dir/platforms/android-14/arch-arm, I use the ndk under the Android SDK, if you rely on your own to download the ndk to compile .

2) –cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi-
set the prefix of the compilation chain, using the compiler of the Android SDK

3) –arch=$CPU
sets the compiled CPU architecture, we are arm

4) --prefix=$PREFIX
specifies the compilation output path, and the corresponding libraries and header files will be generated later

Attach the script:

#!/bin/bash
echo "start configure,waiting...";
SYSROOT=$(pwd)/../prebuilts/ndk/current/platforms/android-14/arch-arm/
TOOLCHAIN=$(pwd)/../prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7
CPU=arm
PREFIX=$(pwd)/out/$CPU

./configure \
    --prefix=$PREFIX \
    --enable-cross-compile \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=$CPU \
    --sysroot=$SYSROOT \
    --extra-libs=-lgcc \
    --disable-shared \
    --enable-static \
    --disable-doc \
    --disable-ffserver \
    --disable-ffmpeg \
    --disable-ffprobe \
    --disable-parsers \
    --enable-parser=aac \
    --disable-indevs \
    --disable-bsfs \
    --disable-devices \
    --disable-muxers \
    --disable-hwaccels \
    --disable-encoders

sleep 1;
make;make install;
exit;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324749823&siteId=291194637