A, linux environment compiler (ubuntu1604_64)
1) Download the source FFmpeg
https://ffmpeg.org/download.html
Download the latest version, ffmpeg-xxxtar.gz, and then extract the command: tar -xjvf ffmpeg-xxxtar.bz2
Git or pulled down, git clone "https://git.ffmpeg.org/ffmpeg.git" ffmpeg
2) Download NDK
https://developer.android.google.cn/ndk/downloads/index.html
You can click to download, can be terminal: wget https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip
Eventually extract to the current directory with uzip command.
May be a little lower down version of such r14b, but there is a compile-time problem, I compile time downloaded 17c, but still have problems, will list them later.
Later do not know, have not tried the latest of how knitting.
PS: In order to facilitate the management and I are a good place to extract a directory, such as:
ls ~/ffmpeg
android NDK-r17c-ffmpeg-4.2.1
3) modify the configuration
The purpose is to compile a dynamic library so android available.
1. Go to ffmpeg directory
cd ~/ffmpeg/ffmpeg-4.2.1/
2. Modify configure
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
changed to
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'
Dynamic library thus generated may be identified naming Android platform.
3. Create a script build_android.sh
In configure the same level directory, create a script build_android.sh, add the following:
#!/bin/bash
set -x
API=28
NDK=D:/NDK/android-ndk-r17c
SYSROOT=$NDK/platforms/android-$API/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
function function_one
{
./configure \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
--disable-doc \
--disable-ffplay \
--disable-ffprobe \
--disable-symver \
--disable-ffmpeg \
--cc=$TOOLCHAIN/bin/arm-linux-androideabi-gcc \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-I$NDK/sysroot/usr/include/arm-linux-androideabi -isysroot $NDK/sysroot -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -marm -march=armv7-a" \
--enable-neon
make clean all
make
make install
}
CPU=armv7-a
PREFIX=$(pwd)/android/$CPU
function_one
When you're done, modify build_android.sh permissions to 777: chmod 777 build_android.sh
Then run the script build_android.sh:./build_android.sh
Two, windows compiler environment (win10)
1) Download the source FFmpeg
https://ffmpeg.org/download.html
2) Download NDK
https://developer.android.google.cn/ndk/downloads/index.html
3) Download MinGW
https://sourceforge.net/projects/mingw/files/
FFmpeg and DNK download and linux like, MinGW is to replace the cmd. You can execute commands similar to linux environment.
After the download, unzip it, and then into the same directory, for example, I have put the D drive.
4) System configuration parameters Environment
In My Computer - Properties - Advanced System Settings - Environment Variables - System variables --Path, add the following path:
D:\MinGW\bin
D:\MinGW\msys\1.0\bin
D: \ NDK \ android-NDK-r17c
OK to return all the way. win + R, input cmd, terminal Enter recall. Ndk-build and are input to verify the configuration gcc -v successful.
5) modify the configuration
1. like linux and enter the ffmpeg directory, modify and configure new build_android.sh
2. Go to the directory D: \ MinGW \ msys \ 1.0, double-click to open msys.bat, you can execute commands like bash linux as;
cd /d/ffmpeg/ffmpeg-4.2.1
chmod 777 build_android.sh
./build_android.sh
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ above is to download the source files and configuration ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑↑↑↑↑↑
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ The following are problems encountered when compiling and solutions ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ↓↓↓↓↓↓↓↓
1. Tip type.h not found
/NDK/android-ndk-r17c/sysroot/usr/include/linux/types.h:21:23: fatal error: asm/types.h: No such file or directory
#include <asm/types.h>
Check in build_android.sh in --extra-cflags = There are no added -isysroot $ NDK / sysroot
2. Tip the variable name B0 problems
libavcodec/aaccoder.c: In function 'search_for_ms':
libavcodec/aaccoder.c:803:25: error: expected identifier or '(' before numeric constant
int B0 = 0, B1 = 0;
^
All the variables B0 libavcodec / aaccoder.c have changed in b0
3. Tip y0000000 'undeclared
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))
All variables libavcodec / hevc_mvs.c files into B0 b0, xB0 into xb0, yB0 into yb0
4. Tip the variable name B0 problems
libavcodec/opus_pvq.c: In function 'quant_band_template':
libavcodec/opus_pvq.c:498:9: error: expected identifier or '(' before numeric constant
int B0 = blocks;
The libavcodec / opus_pvq.c all variables have changed b0 B0
It can normally experienced after these basic errors ed over, programmed library in the ffmpeg-4.2.1 \ android \ armv7-a \ lib.
reference:
https://blog.csdn.net/qq_38261174/article/details/83210458