This is the 7th day of my participation in the November Gwen Challenge. Check out the details: The last Gwen Challenge 2021

Hardware and software Environment

  • Ubuntu 18.04 64 – bit
  • NDK r15c
  • ffmpeg git latest
  • MI MIX 2S

The NDK installation

Download the NDK toolkit, developer.android.com/ndk/downloa… , after decompression on a certain path, I here is/home/xugaoxiang/Tools/the NDK /

Then set two environment variables

export ANDROID_NDK=/home/xugaoxiang/Tools/NDK/android-ndk-r15c
export SYSROOT=$ANDROID_NDK/platforms/android-21/arch-arm
Copy the code

Or write the command to the file ~/.bashrc instead of manually setting it each time

Install separate tool chains

Install a separate toolchain using the installation steps that come with the NDK package, or use the toolchain that comes with the NDK package, which is used in this article. So why bring it up? The advantage of separate toolchains is that they can be installed according to their own needs and compiled goals, once installed, forever used

$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --install-dir=$ANDROID_NDK/.. / toolchains / 21-4.9 - platform = android - 21 - the toolchain = arm - Linux - androideabi - 4.9Copy the code

Download the latest ffMPEG source code

Download the source code using Git

git clone https://git.ffmpeg.org/ffmpeg.git
Copy the code

Compile parameters

The following are the common ffMPEG compilation parameters, which can be modified according to your actual situation, such as x264, X265, AAC support, etc

cd ffmpeg ./configure --arch=arm --cpu=armv7-a - cross - prefix = "$ANDROID_NDK toolchains/arm - Linux - androideabi - 4.9 / prebuilt/Linux - x86_64 / bin/arm - Linux - androideabi -" --sysroot=$SYSROOT --target-os=android --prefix=$PREFIX --disable-static --enable-shared --disable-asm --disable-doc --libdir=$PREFIX/libs/armeabi-v7a --incdir=$PREFIX/includes/armeabi-v7a --pkgconfigdir=$PREFIX/pkgconfig/armeabi-v7aCopy the code

The $PREFIX is the self-specified directory where FFmpeg is installed

Compile the installation

Once configured, you can compile and install

make 
make install
Copy the code

After compiling, ffmpeg/ Android-build generates directories such as bin, includes, and libs

Download the source code

The full project is available on Github, github.com/xugaoxiang/… , the above steps are written in a script for easy operation

The resources

  1. git.ffmpeg.org/ffmpeg.git
  2. Trac.ffmpeg.org/wiki/Compil…
  3. Github.com/WritingMind…
  4. Developer.android.com/ndk/guides/…
  5. medium.com/@karthikcod…