Ffmpeg everywhere, natural Android system without it, tossing a lot of time to complete the NDK compiled Ffmpeg, generated so library reference to the external library librtmp,libx264. All roads lead through Rome,
Maybe there's another better way to do it, and I didn't study it carefully. The method I am using is entirely up to my intended purpose.
I. Choosing a compilation environment
You can choose Cygwin under Windows or you can choose a Linux system, and I recommend choosing the latter. Spend a lot of time compiling under Cygwin, configure always prompt the link needed so file cannot be found. Helpless
To the Linux environment to compile. The version I'm using is ubuntu16.04. Compiling the Android version of FFmpeg Note that there are three places: one is the parameters that are brought in when configure, and the second is to place the
To the third-party library (so), and the last one is to modify the Configure file. Now listen to my one by one-way.
One. Create a shell script file build_ffmpeg.sh is used to introduce the Configure parameter, the format of this file is UNIX, if the file is in DOS format, it can be converted in uedit format.
The shell script created is as follows:
#!/bin/shcpu=Armprefix=$ (PWD)/android/$CPUADDI _cflags="-marm"NDK=/home/wgg/wgg/android-ndk-R11csysroot= $NDK/platforms/android- +/arch-arm/toolchain= $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64./Configure--prefix=$PREFIX--target-os=Linux--enable-cross-Compile--enable-runtime-Cpudetect--disable-ASM--arch=Arm--enable-nonfree--enable-shared--enable-Version3--enable-GPL--disable-Programs--disable-FFmpeg--disable-Ffplay--disable-Ffprobe--disable-Ffserver--disable-Doc--enable-Avresample--disable-everything--enable-decoder=Pcm_alaw--enable-decoder=Pcm_mulaw--enable-decoder=MPEG4--enable-decoder=H264--enable-encoder=AAC--enable-librtmp--enable-libx264--enable-parser=AAC--enable-parser=H264--enable-parser=Mpeg4video--enable-parser=MPEGVideo--enable-parser=Mpegaudio--enable-encoder=libx264--enable-muxer=Mpegts--enable-muxer=flv--enable-muxer=H264--enable-muxer=flv--enable-muxer=mp4--enable-muxer=Data--enable-muxer=avi--enable-muxer=Mpeg2video--enable-muxer=Pcm_alaw--enable-muxer=Pcm_mulaw--enable-demuxer=flv--enable-demuxer=Mpegts--enable-demuxer=RTSP--enable-protocol=Httpproxy--enable-protocol=Crypto--enable-protocol=FTP--enable-protocol=Unix--enable-protocol=Pipe--enable-protocol=Data--enable-protocol=file--enable-protocol=TCP--enable-protocol=http--enable-protocol=UDP--enable-protocol=Udplite--enable-protocol=RTP--enable-protocol=librtmp--enable-protocol=Librtmpe--enable-protocol=Librtmps--enable-protocol=librtmpt--enable-protocol=Librtmpte--enable-protocol=Async--enable-protocol=MD5--enable-protocol=Cache--enable-protocol=MmSt--enable-protocol=Mmsh--sysroot=$SYSROOT--cross-prefix= $TOOLCHAIN/bin/arm-linux-androideabi- --enable-Hwaccels--enable-zlib--disable-Devices--disable-Avdevice--extra-cflags="-os-fpic $ADDI _cflags" --extra-cflags="-i/home/wgg/wgg/ffmpeg/extern/include" --extra-ldflags="-l/home/wgg/wgg/ffmpeg/extern/lib"
NDK Specifies the NDK package path, Sysroot is the path prefix, compile is the compiler will go to the system path (for example,/usr/lib,/lib), define the Sysroot after the original system path is compiled before adding $sysroot, expression
The android-21 to be reset according to the actual Android. The Configure option can be pruned as needed. --extra-cflags= "-i/home/wgg/wgg/ffmpeg/extern/include" indicates the header file absolute path of the external library,--extra-ldflags= "-l/home/wgg/wgg/ffmpeg/ Extern/lib "indicates the external so library path.
Two. Placing external libraries and header files
Place the librtmp.so libx264 libcrypto.so libssl.so After the two libraries are the first library's dependent libraries placed under/home/wgg/wgg/ffmpeg/extern/lib. Place the X264.h, X264_config.h, and rtmp folders in the/home/wgg/wgg/ffmpeg/extern/include directory with the following files in the Rtmp folder.
Three. Modify the configuration file
Enabled Librtmp && require_pkg_config librtmp librtmp/rtmp.h rtmp_socket
Modified into
Enabled librtmp && require librtmp librtmp/rtmp.h rtmp_socket-lrtmp
Will
Enabled libx264 && {use_pkg_config x264 "stdint.h x264.h" X264_encoder_encode | | {Require libx264 x264.h x264_encoder_encode-lx264 && warn "using libx264 without Pkg-config";}} && {check_cpp_condition x264.h "x264_build >= 118" | | Die "error:libx264 must is installed and version must be >= 0.118."; } && {check_cpp_condition x264.h "X264_MPEG2" && enable libx262;}
Replaced by
Enabled libx264 && require libx264 x264.h x264_encoder_encode-lx264
Modify build_ffmpeg.sh permissions chmod +x build_ffmpeg.sh
OK, all the preparations are done. First,/build_ffmpeg.sh, then make final make install.
Note: I use the FFMEPG version is 3.0.2,librtmp,libx264 basic without changes, direct reference so no need to compile. Get External Reference Library please join QQ Group
Streaming media/ffmpeg/audio and video 127903734.
Anroid NDK compiled ffmpeg reference librtmp libx264