NDK compilation Ffmpeg[linux]

Source: Internet
Author: User

Recently in the study of video-related technology, learned ffmpeg, on the internet to see how to transplant FFmpeg to Android, looked for a few days, look at a lot of things, is not a complete transplant successful, and finally through the production of various materials, combined with online information, Finally, the ffmpeg was done. Record it here.

Overall concept:

Build the NDK build environment under Centos7.5, compile the FFmpeg library, build the library files needed for Android, and use it in Android

Preparatory work:

1. Install the CentOS system in the virtual machine

2. Download NDK

Linux + bit
Http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86.bin
Linux a bit
Http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86_64.bin

3. Download FFmpeg source code

: http://www.ffmpeg.org/download.html

Create a new folder under Centos/usr/local Ndk, Android-ndk-r10d-linux-x86_64.bin and ffmpeg source upload to the folder.

First, installation

1. Installing the NDK

[Email protected]/]# CD/USR/LOCAL/NDK

[Email protected] ndk]# chmod a+x android-ndk-r10d-linux-x86_64.bin

Perform the above action, set the executable file, and then execute the./android-ndk-r10d-linux-x86_64.bin Installing the NDK

The corresponding folder is generated in the current directory when the installation is complete

2, Installation Dos2unix

Yum Install Dos2unix
Dos2unix **.sh

If you do not install Dos2unix, the following error is reported at compile time:

$ ' \ R ': Command not Found

Unexpected syntax error near symbol ' $ ' {\ R '

3. Installing gcc and C + +

Yum Install gcc-c++

If not installed, the following error will be reported

4, Installation Yasm

# wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
# tar ZXVF yasm-1.3.0.tar.gz
# CD yasm-1.3.0
#./configure
# Make && make install

After the above steps, the environment is configured, the following will start compiling ffmpeg

5. Compiling ffmpeg

[Email protected] ffmpeg]# Cd/usr/local/ndk/ffmpeg

[Email protected] ffmpeg]# VI config_android.sh

Copy the following script in

ndk=/usr/ndk/android-ndk-r10d

sysroot= $NDK/platforms/android-9/arch-arm/

toolchain= $NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64

function Build_one

{

./configure \

--prefix= $PREFIX \

--enable-shared \

--disable-static \

--disable-doc \

--disable-ffmpeg \

--disable-ffplay \

--disable-ffprobe \

--disable-ffserver \

--disable-avdevice \

--disable-doc \

--disable-symver \

--cross-prefix= $TOOLCHAIN/bin/arm-linux-androideabi-\

--target-os=linux \

--arch=arm \

--enable-cross-compile \

--sysroot= $SYSROOT \

--extra-cflags= "-os-fpic $ADDI _cflags" \

--extra-ldflags= "$ADDI _ldflags" \

$ADDITIONAL _configure_flag

Make clean

Make

Make install

}

Cpu=arm

prefix=$ (PWD)/android/$CPU

Addi_cflags= "-marm"

Build_one

NDK Installation path for NDK

Compiling ffmpeg

[Email protected] ffmpeg]# chmod a+x *

[Email protected] ffmpeg]#./config_android.sh

This process if not error, will wait for a long time, wait for the end of the FFmpeg folder will be more than an Android folder, containing the ffmpeg. so files and header files

We just need to copy the Android folder to the Windows environment!

At this point, FFmpeg has been compiled and completed

How to use the next main record in Android development

NDK compilation Ffmpeg[linux]

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.