x264 compilation scripts for iOS and Android two platforms

Source: Internet
Author: User

this year did a number of audio and video codec work, before doing graphics, image class work more, do the audio and video codec to know, this work is very interesting, very magical. For example, the acquisition of dozens of m of video data, after encoding storage, the file volume is only dozens of k size, which requires x264 to play the magic. Below the mobile phone-side iOS and Android two platform under the x264 compilation script to share, hope to be doing related work of the students to help. x264 Source Address: http://www.videolan.org/developers/x264.html1. x264 compilation under iOS platform. This compilation script is modified from: https://github.com/xlking/build_x264, sometimes Hou Jin think GitHub is really omnipotent, there are too many good things. This compilation script feature is rich, will compile the simulator and the real machine two static library at the same time, and finally will combine two libraries as a static library, I found in the actual application, x264 in the video encoding process some modules need the hardware instruction support, but the simulator does not provide this kind of hardware instruction, So with the simulator debugging Video Coding program, all of the program crashes, the proposed unification with the real machine debugging, can save a lot of time, less go a lot of detours. Another thing to say is that this compilation script optional parameters, and now iOS8 has come out, I was at compile time is still ios7.1, so the script sdk_version options, can be modified as appropriate. The script reads as follows:
#!/bin/shcd x264dest=installsdk_version= "7.1" echo "Building armv7" arm= "armv7" Export 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: $DES T/$ARM "echo" Building i386 "sim=" i386 "cc=/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-a pple-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/$SIM" echo "Combining library .... .." build_libs= "libx264.a" output_dir= "OUTPUT" archs= "ARMv7 i386" CD Installmkdir $OUTPUT _dirmkdir $OUTPUT _dir/libmkdir $ Output_dir/includelipo_create= "" For the 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. x264 compilation under Android platform. In addition to download x264 source code, but also to build the NDK development environment, this is easy, as long as the website to download the appropriate platform NDK package can be. Complete the NDK environment Setup, the next step is to execute the script, compile x264 source code. First, create a new build_x264.sh script file in the x264 source directory and copy the following into the file and save it. Open the terminal, CD into the x264 directory, execute./build_x264.sh, follow the prompts to enter make, and then wait patiently for the results to be compiled. The script reads 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
with the libx264.a file, the next step is to call the appropriate API to do video coding. Of course, you can also use FFmpeg to do audio and video coding, simply open the support libx264 option when compiling ffmpeg.


x264 compilation scripts for iOS and Android two platforms

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.