Using Cygwin ndk_r9c to compile ffmpeg in a Windows environment

Source: Internet
Author: User

One, nonsense

In recent studies, the first step is to compile. We need to compile the FFMPAG,X264,FDK_AAC, one step at a time. First of all, say FFmpeg, many of the internet is hundreds of years ago, I test perfect available

Contact me can directly comment, also can add me qq:11635423

Second, dry goods

My ability is limited, but I hope that what I write can make more people accept it. I was just in touch. Make a record and hope it will be good for everyone else.

A few concepts to understand: don't understand it's okay. After that, it's time to understand. Mainly because we are Windows

First, some concepts under the Cygwin:
Unix style path:/cygdrive//directory Name/file name (in fact:/path/to/Mount/point/path/to/file)
Mixed style path: drive letter:/directory name/file name
Windows style Path: drive letter: \ directory name \ FileName

Use Cygpath to convert between these path forms
Cygpath-m"Path"
Cygpath-u"Path"
Cygpath-W"Path"

Preparation: 1. Source Code of FFmpeg

2.cygwin Download, install, this online basically have. I don't talk too much. Git cygdrive bash make these are all needed to download

3.NDK my current version r9c. The latest should be to r9d now. The need to update the problem is not big. And note setting environment variables

My settings are as follows: because the following command needs to be used, so it is not set as I set the same as well, to avoid unnecessary problems

Android_ndk_root E:\android-ndk-r9c\

The name is just as good, the path is your own.

4. Compile the script. This script is understood by itself. Me too smattering--script name: config.sh

Echo"ffmpeg_source_dir= $FFMPEG _source_dir"
Extra_options= ()

Case$OSinch
Android)
Gnu_build_os=linux

Case$ARCHinch
armeabi-v7a*)
Target_arch=arm
Gnu_build_arch=armv7-a

crosscompile_prefix=arm-linux-androideabi-

extra_options+= (
--cpu=cortex-a9
--extra-cflags=-mfpu=vfpv3-d16
--extra-cflags=-dandroid
--extra-cflags=-gdwarf-2
--disable-fast-unaligned
--extra-cflags=-mno-unaligned-access
)
;;
Esac


Case$ARCHinch
Armeabi-v7a-hard)
app_platform=android- +

extra_options+= (
--extra-cflags=-mhard-float
--extra-cflags=-d_ndk_math_no_softfp=1
--extra-libs=-lm_hard
--EXTRA-LDFLAGS=-WL,--No-warn-mismatch
)
;;
ARMEABI-V7A)
app_platform=android-8
;;
Esac

sysroot="${android_ndk_root}/platforms/${app_platform}/arch-${target_arch}"
;;
Windows)
Case$ARCHinch
x86_64)
crosscompile_prefix=x86_64-w64-mingw32-
extra_options+= (
--extra-cflags=-m64
)
;;
Esac

Gnu_build_os=mingw32
Gnu_build_arch= $ARCH
;;
Linux)
Gnu_build_os=linux
Gnu_build_arch= $ARCH
;;
Esac

Install_subdir=${os}/${arch}

Echofdk_aac_install_dir= $FDK _aac_install_dir
Echox264_install_dir= $X 264_install_dir


$FFMPEG _source_dir/configure \
--prefix=/\
--sysroot=${sysroot} \
--cross-prefix=${crosscompile_prefix} \
--arch= $GNU _build_arch \
--target-os= $GNU _build_os \
"${extra_options[@]}"\
--extra-cflags="-i${fdk_aac_install_dir}/include"\
--extra-cflags="-i${x264_install_dir}/include"\
--extra-ldflags="-l${fdk_aac_install_dir}/lib"\
--extra-ldflags="-l${x264_install_dir}/lib"\
\
--ENABLE-GPL \
--enable-version3 \
--enable-nonfree \
\
--enable-pic \
\
--disable-swscale-alpha \
--disable-doc \
--disable-network \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-postproc \
\
--disable-everything \
\
--enable-demuxer=mov \
--enable-demuxer=mpegts \
--enable-demuxer=mp3 \
--enable-demuxer=pcm_s16le \
--enable-demuxer=rawvideo \
\
--enable-muxer=mp4 \
--enable-muxer=mpegts \
--enable-muxer=pcm_s16le \
--enable-muxer=rawvideo \
\
--ENABLE-DECODER=AMRNB \
--ENABLE-DECODER=AMRWB \
--enable-decoder=h264 \
--ENABLE-DECODER=MPEG4 \
--enable-decoder=h263 \
--enable-decoder=h263p \
--enable-decoder=mp3 \
--enable-decoder=pcm_s16le \
--ENABLE-DECODER=AAC \
--enable-decoder=rawvideo \
\
--ENABLE-ENCODER=LIBFDK_AAC \
--enable-encoder=libx264 \
--enable-encoder=pcm_s16le \
--enable-encoder=rawvideo \
\
\
--ENABLE-BSF=AAC_ADTSTOASC \
--ENABLE-BSF=H264_MP4TOANNEXB \
\
--enable-filter=scale \
--enable-filter=aresample \
--enable-filter=resample \
--enable-filter=transpose \
--enable-filter=vflip \
--enable-filter=hflip \
--enable-filter=crop \
--enable-filter=amix \
--enable-filter=pan \
\
--enable-protocol=file\
\
--enable-parser=mpegaudio \
--enable-parser=mpeg4video \
--enable-parser=h264 \
--enable-parser=h263 \
--ENABLE-PARSER=AAC \
--ENABLE-PARSER=AAC_LATM \

Third, compile

FFmpeg

1. Navigate to the compiled directory
2. Execute the following command
tmp=$ (cygpath-m"$TMP") \
ARCH=ARMEABI-V7A \
Os=android \
android_ndk_root=$ (cygpath-m"$ANDROID _ndk_root") \
Ffmpeg_source_dir=/cygdrive/e/soft/source/ffmpeg \
/cygdrive/e/qupai_code_eclipse/code/thirdparty/build/ffmpeg/config.SH
3. Modify Config.h config.mk Makefile path problem

config will also need to modify the path in Src_path and makefile (not src_dir) in Config.mak under the build directory and change it to mixed style

4. Execute the Make command-note that the NDK make is used here.
" $ANDROID _ndk_root/prebuilt/windows/bin/make " -j8
5. Execute the install--note that the NDK make is used here.
" $ANDROID _ndk_root/prebuilt/windows-x86_64/bin/make " Install destdir=" specified installation directory, mixed style"

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.