Cross-compiling FFMPEG:AAC x264 x265

Source: Internet
Author: User
Tags git clone

These days have been tossing in Ubuntu under the cross-compiling arm platform FFmpeg, as a standard Windows users, in the Linux toss really laborious, now the compilation process is recorded, mainly x265 compilation too toss people! The cross-compilation environment is self-configuring.

Cross-compiling aac:1. Download AAC Source

Wget-o fdk-aac.tar.gz https://github.com/mstorsjo/fdk-aac/tarball/master
tar xzvf fdk-aac.tar.gz
2. Run autogen.sh to generate the Configure file if an error occurs at this time:
Can ' t exec "libtoolize": No such file or directory at/usr/bin/autoreconf line 190. Install libtool.deb or UPDATE command under Ubuntu: Apt-get install Libtool 3. Execute Configure generate Makefile file
./configure--PREFIX=/MY/DM3730/FDKAAC--host=arm-none-linux-gnueabi--disable-shared
4.make 5.sudo make install at this time if the slaughter ranlib can not find, then sudo printdev see if the environment variable is good if not, then edit the/etc/sudoers file configuration environment variable, execute sudo make again Install

Cross-compiling x264 1. Download mp4 Source code
sudo git clone git://git.videolan.org/x264
2. Run Configure build Makefile
sudo./configure--prefix=/my/dm3730/x264--enable-static--host=arm-none-linux-gnueabi--cross-prefix= arm-none-linux-gnueabi---disable-asm
3.make 4.make Install
Cross-compiling x265 1. Download source code http://ftp.videolan.org/pub/videolan/x265/
I'm using version 1.9.
Note: FFmpeg the address of the x265 in the documentation is: HG clone https://bitbucket.org/multicoreware/x265, but the source code is problematic,
One of the x265.h in the implementation of a struct is completely C + + style, the structure contains functions, so ffmpeg is compiled does not pass, but this version has a benefit is specifically a
arm-linux cross-compiling directory, which created a toolchain, Compiling is convenient
2. Manually create a toolchain into the build directory, create a Arm-linux subdirectory, enter the Arm-linux directory, and create Make-makefiles.bash and toolchain.cmake two files respectively Write in Make-makefiles.bash:
#!/bin/bash
# Run This from within a bash shell

cmake-dcmake_toolchain_file=toolchain.cmake-g "Unix makefiles". ./.. /source && Ccmake. /.. /source
Write in Toolchain.cmake
# CMake Toolchain file for cross compiling x265 for ARM Arch
set (cross_compile_arm 1)
set (Cmake_system_name Linux)
set (Cmake_system_processor armv6l)
# Specify the Cross compiler
set (Cmake_c_compiler ARM-NONE-LINUX-GNUEABI-GCC)
set (Cmake_cxx_compiler arm-none-linux-gnueabi-g++)
# Specify the target Environment
SET (Cmake_find_root_path  /home/kamui/work/toolchain/toolchain/codesourcery/sourcery_g++_ Lite/bin)
chmod 777 Make-makefiles.bash 3. sudo sh./make-makefiles.bash
Note: x265 compiled using CMake, the CMake version of the higher requirements, as far as possible with the latest source code to compile a cmake
After running this step, will pop up a directory selection box, the Cmake_install_prefix point to the directory you need to install, note that the prefix in the toolchain settings as if it does not take effect, so here under the selection, after setting, press C, and then press G to continue 6.sudo Make
In the process of compiling if the following error:
1. If at this time in compiling the CLI times wrong final link failed:nonrepresentable section on output, then modify Toolchan, add set (Cmake_exe _linker_flags "-fpic-shared")
and then re-execute from step 3
2. If you report an error in the uses VFP register arguments type, it is an issue of cross-compiling floating-point types. Floating-point compilation type is easy to encounter in cross-compilation, after I run Make-makefiles.bash static,share,cli connection type is hard,
compile error, need to change to soft, But in the CMake parameter I tried the flags setting the floating-point type is not in effect, so you can only manually change the makefile file, Several makefile files are generated after the Make-makefiles.bash is executed, and the compilation connection options in each makefile file are in the Flags.make file:
encoder/cmakefiles/ Encoder.dir/flags.make     
common/cmakefiles/common.dir/flags.make   
cmakefiles/cli.dir/flags.make    
Cmakefiles/x265-shared.dir/flags.make   
Cmakefiles/x265-static.dir/flags.make 
Each of the five documents "-mfloat-abi= Hard "change to"-mfloat-abi=soft "or"-MFLOAT-ABI=SOFTFP "and
then specify step 6 for make, then it should be OK
7.sudo make Install
Cross-compiling ffmpeg 1. Download the source code
git clone git://source.ffmpeg.org/ffmpeg.git
2.pkg-config
Copy the/usr/bin/pkg-config to the directory where the cross-compilation environment is located, with ARM-NONE-LINUX-GNUEABI-GCC in the same directory, and renamed Arm-none-linux-gnueabi-pkg-config, The reason for this is that ffmpeg in the configure, it is necessary to find x265 x265.pc file, and x264 no words, by specifying the Lib directory and the header file can be.
2. Run Configure build Makefile
sudo./configure--prefix=/my/dm3730/ffmpeg--enable-cross-compile--cross-prefix=arm-none-linux-gnueabi---arch= Armel--target-os=linux--ENABLE-GPL--enable-nonfree--extra-cflags= "-i/my/dm3730/fdkaac/include-i/my/dm3730/x264 /include-i/my/dm3730/x265/include "--extra-ldflags="-l/my/dm3730/fdkaac/lib-l/my/dm3730/x264/lib-l/my/dm3730/ X265/lib "--enable-libfdk-aac--enable-libx264--enable-libx265--pkg-config-flags=--static--extra-libs="-ldl-fpic -shared "--enable-shared--disable-ffmpeg--disable-ffplay--disable-ffprobe--disable-ffserver<span style=" Background-color:inherit; line-height:1.5; " ></span>
At this time if the "x265 not found using Pkg-config" error, then check/usr/local/lib/pkgconfig/x265.pc, if this file does not exist then you compile x265 when the directory specified in the copy come Configure success is as follows:

3.sudo make
4.sudo make Install

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.