FFmpeg 3.2.4 + libx264 Windows compilation summary

Source: Internet
Author: User

___________________________ compilation Environment __________________________________

NDK Environment: android-ndk-r13b

MinGW Environment: Basic setup under Mark all projects, ffmpeg need to use Msys environment to compile

ffmpeg:3.2.4

libx264: Latest website

_____________________________________________________________________

___________________________ Compiling configuration ___________________________________

Create a new sh file under the extracted FFmpeg directory and fill in the following content

The key variable setting is the NDK path

 #!/bin/bash ndk=e:/android-ndk-r13bsysroot= $NDK/platforms/android-19/arch-arm/toolchain= $NDK/toolchains/      Arm-linux-androideabi-4.9/prebuilt/windows-x86_64function build_one {./configure--prefix= $PREFIX--enable-asm --enable-neon--enable-static--enable-small--disable-shared--disable-ffmpeg--DISABLE-FFP Lay--disable-ffprobe--disable-ffserver--disable-avdevice--disable-doc--disable-symver- -cross-prefix= $TOOLCHAIN/bin/arm-linux-androideabi---target-os=linux--arch=arm--cpu=armv7-a--enabl E-cross-compile--sysroot= $SYSROOT--extra-cflags= "-fpic-dandroid-mfpu=neon-mfloat-abi=softfp-i$ndk/platform  S/android-19/arch-arm/usr/include "--extra-ldflags=" $ADDI _ldflags "make, make, make install} Cpu=arm prefix=$ (pwd)/android/$CPU addi_cflags= "-marm" Build_one 

The

comes with a compile script that joins the libx264 library (extra_lib points to the libx264 compiled directory, including header files [include] and static library [LIB] folders):

#!/bin/bash ndk=e:/android-ndk-r13bsysroot= $NDK/platforms/android-19/arch-arm/toolchain= $NDK/toolchains/ Arm-linux-androideabi-4.9/prebuilt/windows-x86_64extra_lib=e:/ffmpeg/android-libfunction Build_one {./configure- -prefix= $PREFIX--enable-asm--enable-neon--enable-static--enable-small--enable-libx264- -ENABLE-GPL--enable-encoder=libx264--disable-shared--disable-doc--disable-ffmpeg--disable-ff Play--disable-ffprobe--disable-ffserver--disable-avdevice--disable-symver--cross-prefix= $TOO      lchain/bin/arm-linux-androideabi---target-os=linux--arch=arm--cpu=armv7-a--enable-cross-compile --sysroot= $SYSROOT--extra-cflags= "-I$EXTRA_LIB/INCLUDE-FPIC-DANDROID-MFPU=NEON-MFLOAT-ABI=SOFTFP-I$NDK/PLATF      Orms/android-19/arch-arm/usr/include "--extra-ldflags="-l$extra_lib/lib-lx264 $ADDI _ldflags "Make clean Make make install} cpu=arm prefix=$ (PWD)/android/x264_lib/$CPU addi_cflags= "-marm" Build_one 

After compiling, Eclipse creates a new project, adds C + + library support, writes a Java JNI interface, and, under the bin classes directory, uses Javah to generate the header file.

Attach the main implementation code, as well as two compiled MK file notation:

Android.mk

Local_path: = $ (call my-dir) # Prepare Libxinclude $ (clear_vars) Target_arch_abi: = armeabi-v7alocal_export_c_includes: = $ (local_path)/includelocal_module: = avcodeclocal_src_files: = Libavcodec.ainclude $ (prebuilt_static_library) # Prepare Libxinclude $ (clear_vars) Target_arch_abi: = Armeabi-v7alocal_export_c_includes: = $ (Local_path)/includeLOCAL _module: = avfilterlocal_src_files: = Libavfilter.ainclude $ (prebuilt_static_library) # Prepare Libxinclude $ (CLEAR_VAR S) Target_arch_abi: = Armeabi-v7alocal_export_c_includes: = $ (local_path)/includelocal_module: = AvformatLOCAL_SRC_ FILES: = Libavformat.ainclude $ (prebuilt_static_library) # Prepare Libxinclude $ (clear_vars) Target_arch_abi: = Armeabi-v7alocal_export_c_includes: = $ (local_path)/includelocal_module: = Avutillocal_src_files: = Libavutil.ainclude $ (prebuilt_static_library) # Prepare Libxinclude $ (clear_vars) Target_arch_abi: = Armeabi-v7aLOCAL_ Export_c_includes: = $ (local_path)/includelocal_module: = Postproclocal_src_fileS: = Libpostproc.ainclude $ (prebuilt_static_library) # Prepare Libxinclude $ (clear_vars) Target_arch_abi: = Armeabi-v7alocal_export_c_includes: = $ (local_path)/includelocal_module: = Swresamplelocal_src_files: = Libswresample.ainclude $ (prebuilt_static_library) # Prepare Libxinclude $ (clear_vars) Target_arch_abi: = Armeabi-v7alocal_export_c_includes: = $ (local_path)/includelocal_module: = Swscalelocal_src_files: = Libswscale.ainclude $ (prebuilt_static_library) # Prepare Libxinclude $ (clear_vars) Target_arch_abi: = Armeabi-v7aLOCAL _export_c_includes: = $ (local_path)/includelocal_module: = x264local_src_files: = Libx264.ainclude $ (PREBUILT_STATIC_ LIBRARY) include $ (clear_vars) Target_arch_abi: = Armeabi-v7alocal_module: = nativeapptestlocal_src_files: = Nativeapptest.cpplocal_c_includes + = $ (local_path)/includelocal_cflags: =-d__stdc_constant_macros- Wno-sign-compare-wno-switch-wno-pointer-sign-dhave_neon=1-mfpu=neon-mfloat-abi=softfp-fpic-dandroidlocal_ Static_libraries:= Avfilter Avformat avcodec postproc swresample swscale avutil x264local_ldlibs: =-l$ (ndk_root)/platforms/$ (APP_PLATF ORM)/arch-arm/usr/lib-l$ (Local_path)-llog-ljnigraphics-lz-ldlinclude $ (build_shared_library)

Application.mk

App_stl: = gnustl_staticapp_ldflags: =-latomicapp_abi: = armeabi-v7aapp_platform: = android-19

NativeApp.cpp (because FFmpeg is a pure C implementation, so when referring to the header in the CPP file, add [extern "C"] package) Otherwise the compilation will appear the following error:

jni/nativeapptest.cpp:21:error:undefined reference to ' avcodec_configuration () ' Clang++.exe:error:linker command Failed with exit code 1 (use-v to see invocation) Make: * * * [obj/local/armeabi-v7a/libnativeapptest.so] Error 1
#include <jni.h>extern "C"{#include"libavcodec/avcodec.h"} #include<com_ltz_nativeapptest_anative_DoInFastMode.h>/** Class:com_ltz_nativeapptest_anative_doinfastmode * method:getversion * Signature: () I*/jniexport jint jnicall java_com_ltz_nativeapptest_anative_doinfastmode_getversion (jnienv*, Jclass) {    return 0;} Jniexport jstring jnicalljava_com_ltz_nativeapptest_anative_doinfastmode_getcfg (JNIEnv*env, Jclass) {    //TODO    Charinfo[10000] = {0}; sprintf (Info,"%s\n", Avcodec_configuration ()); returnEnv->Newstringutf (info);}

In addition, the JNI directory structure is attached:

______________________________ Failure Part Summary ________________________________________

FFmpeg uses the latest code from the Master branch, with the NDK r10c and r13b having a confusing error in compiling AVCODEC:

1 is the Search_for_ms function in the aaccoder.c file that initializes the B0,B1 report symbol error. Suspect variable name and macro conflict, so instead of BC0,BC1, change the file compiled by.

2: Macro definitions for HEVC_MVS.C files

#define TAB_MVF_PU (v)                                                       TAB_MVF ((((x # # V) >> s->ps.sps->log2_min_pu_size), ((                                 y # # V) >> s-> Ps.sps->log2_min_pu_size))

The prompt cannot find x, y because it is unclear what the operator "# #" means, so the problem has not been resolved for the time being.

FFmpeg 3.2.4 + libx264 Windows compilation summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.