Compile FFmpeg for Android NDK (complex environment variable settings are not required)

Source: Internet
Author: User

Environment: CentOS6.2 -- 64-bit create the work folder: cd/& mkdir worka in the root directory) first download the installation package to the local machine: FFmpeg: git clone git: // source.ffmpeg.org/ffmpeg.git ffmpeg must be optimistic about downloading the software package version of the corresponding local system. The Created directory structure is: work/ffmpeg work/android-ndk-r8bb) Configure environment variables: (can be omitted) export ANDROID_NDK_HOME =/work/android-ndk-r8bexport PATH = $ ANDROID_NDK_HOME: $ PATHc) enter the ffmpeg directory, create config. sh file, and write the following text to the file: [plain] export ANDROID_NDK =/work/android-ndk-r8b export TOOLCHAIN =/work/tmp/ffmpeg export SYSROOT = $ TOOLCHAIN/sysroot/$ ANDROID_NDK/build/tools/make-standalone-toolchain.sh -- platform = android- 14 -- install-dir = $ TOOLCHAIN exp Ort PATH = $ TOOLCHAIN/bin: $ PATH export CC = arm-linux-androideabi-gcc export LD = arm-linux-androideabi-ld export AR = arm-linux-androideabi-ar CFLAGS = "-O3-Wall- mthumb-pipe-fpic-fasm \-finline-limit = 300-ffast-math \-fstrict-aliasing-Werror = strict-aliasing \-fmodulo-sched-allow -regmoves \-Wno-psabi-Wa, -- noexecstack \-d1_arm_arch_5 _-d1_arm_arch_5e _ \-d1_arm_arch_5t _-d1_arm _ ARCH_5TE _ \-DANDROID-DNDEBUG "EXTRA_CFLAGS ="-march = armv7-a-mfpu = neon-mfloat-abi = softfp-mvectorize-with-neon-quad "EXTRA_LDFLAGS ="-Wl, -- fix-cortex-a8 "FFMPEG_FLAGS =" -- prefix =/tmp/ffmpeg/build \ -- target-OS = linux \ -- arch = arm \ -- enable-cross-compile \ -- cc = arm- linux-androideabi-gcc \ -- cross-prefix = arm-linux-androideabi-\ -- enable-shared \ -- disable-symver \ -- disable-doc \ -- disable-ffplay \ -- Disable-ffmpeg \ -- disable-ffprobe \ -- disable-ffserver \ -- disable-avdevice \ -- disable-avfilter \ -- disable-encoders \ -- disable-muxers \ -- disable-filters \ -- disable-devices \ -- disable-everything \ -- enable-protocols \ -- enable-parsers \ -- enable-demuxers \ -- disable-demuxer = sbg \ -- enable-decoder = h264 \ -- enable-bsfs \ -- enable-network \ -- enable-swscale \ -- enable-asm \ -- enable-version 3 ". /configure $ FFMPEG_FLAGS -- extra-cflags = "$ CFLAGS $ EXTRA_CFLAGS" -- extra-ldflags = "$ EXTRA_LDFLAGS" make clean make-j4 make install of course, the configure parameter can be specified as needed. D) Execution file :. /config. sh at this time may have a variety of problems, don't panic, look at config. log file, if there is a problem like/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory at this time, it is necessary to use google, the omnipotent google, the gospel of programmers, it seems that the library dependency is missing. It doesn't matter. Execute yum install alibc. i686 seems to be able to solve the problem, and then proceed. /config. sh again reported an error :/.. /lib/gcc/arm-linux-androideabi/4.6 /.. /.. /.. /.. /arm-linux-androideabi/bin/as: error while loading shared libraries: libz. so.1: cannot open shared object fi Le: No such file or directory, but it doesn't matter. There is a omnipotent google. It seems that zlib is missing. Well, execute yum install zlib as before. i686 may prompt about installation failure or something. At this time, you need to download the latest zlib from the official website: http://zlib.net/download and decompress it. The problem may have been fixed after you enter the directory, the lib file is installed incorrectly. configure is installed in/usr/local/lib by default. It doesn't matter. Set a soft link at this time: mv. /lib/libz. so.1. /lib/libz. so.1 _ backupln-s/usr/local/lib/libz. so.1. /lib/libz. so.1 Go To The ffmpeg directory again and execute :. /config. sh if the problem persists, prompt mysql or something, Tell you a trick yum install mysql-embedded.i686 ^ o ^ it's okay to execute. /config. sh ..................................................................................................................... ........................................................................................................................ ........................................................................................................................ ......... Long compilation process ...... The final result is as follows: Enter/tmp/ffmpeg/sysroot/usr and you will see the desired header file and library file. The corresponding lib folder of ffmpeg is also generated. so file.

Related Article

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.