Compile scripts for x264 on ios and android platforms

Source: Internet
Author: User

Compile scripts for x264 on ios and android platforms
This year, I did some audio/video coding and decoding work. I had done a lot of work on graphics and images before, and I realized it was interesting and amazing. For example, after collecting dozens of MB of video data and encoding and storage, the file size is only dozens of KB, which requires x264 to be magical. Below we will share the x264 compilation script on the mobile ios and android platforms, hoping to help those who are doing the relevant work. X264 Source Code address: http://www.videolan.org/developers/x264.html 1. ios platform x264 compilation. This compilation script is modified from: Compile. This compilation script has rich functions. It will compile both the simulator and the real machine static library at the same time, and finally combine the two libraries into a static library. I found in practical applications that, some modules of x264 require hardware instruction support in the video encoding process, but the simulator does not provide such hardware instruction. Therefore, when the simulator is used to debug the video encoding program, the program crashes, it is recommended that you use a real machine for debugging in a unified manner, which saves a lot of time and reduces detours. In addition, there are a lot of optional parameters for this compilation script. Now ios8 has come out. I was still compiling ios7.1, so the sdk_version option in the script can be modified as appropriate. The script content is as follows:

#!/bin/shcd x264DEST=installSDK_VERSION=7.1echo Building armv7ARM=armv7export CC=`xcodebuild -find clang`DEVPATH=/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDK_VERSION}.sdk./configure                         --host=arm-apple-darwin         --sysroot=$DEVPATH              --prefix=$DEST/$ARM             --extra-cflags=-arch $ARM     --extra-ldflags=-L$DEVPATH/usr/lib/system -arch $ARM     --enable-pic          --enable-static       --enable-asm    make && make install && make cleanecho Installed: $DEST/$ARMecho Building i386SIM=i386CC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gccDEVPATH=/Applications/XCode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDK_VERSION}.sdk./configure                         --host=i386-apple-darwin         -sysroot=$DEVPATH              --prefix=$DEST/$SIM             --extra-cflags=-arch $SIM     --extra-ldflags=-L$DEVPATH/usr/lib/system -arch $SIM     --enable-pic        --enable-static     --disable-asm    make && make install && make cleanecho Installed: $DEST/$SIMecho Combining library ......BUILD_LIBS=libx264.aOUTPUT_DIR=outputARCHS=armv7 i386cd installmkdir $OUTPUT_DIRmkdir $OUTPUT_DIR/libmkdir $OUTPUT_DIR/includeLIPO_CREATE=for ARCH in $ARCHS; do    LIPO_CREATE=$LIPO_CREATE $ARCH/lib/$BUILD_LIBS donelipo -create $LIPO_CREATE -output $OUTPUT_DIR/lib/$BUILD_LIBScp -f $ARCH/include/*.* $OUTPUT_DIR/include/echo ************************************************************lipo -i $OUTPUT_DIR/lib/$BUILD_LIBSecho ************************************************************echo OK, merge done!
2. Compile x264 on the android platform. In addition to downloading the x264 source code, you also need to build an ndk development environment. This is easy, as long as you download the ndk package of the corresponding platform from the official website. After the ndk environment is set up, the next step is to execute the script and compile the x264 source code. First, create the build_x264.sh script file in the x264 source code directory, copy the following content to the file and save it. Open the terminal, cd to enter the x264 directory, execute./build_x264.sh, enter make as prompted, and then wait patiently for the compilation result. The script content is as follows:
export NDK=/home/mypc/android-ndk-r9dexport PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuiltexport PLATFORM=$NDK/platforms/android-8/arch-armexport PREFIX=/home/mypc/x264./configure --prefix=$PREFIX --enable-static --enable-pic --disable-asm --disable-cli --host=arm-linux --cross-prefix=$PREBUILT/linux-x86/bin/arm-linux-androideabi- --sysroot=$PLATFORM



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.