Compiling FFmpeg in Linux supports x264 and x265

Source: Internet
Author: User

Compiling FFmpeg in Linux supports x264 and x265

1. Preface

Ffmpeg, x264, x265

2. environment dependency

2.1 Delete the ffmpeg library installed in the system.
Sudo apt-get -- purge remove ffmpeg mplayer x264 x265

2.2 install dependency Libraries
Sudo apt-get update
Sudo apt-get-y -- force-yes install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev \
Libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
Libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev

Note: The server version can be ignored.
Libsdl1.2-dev libva-dev libvdpau-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev

2.3 download source code

(1) ffmpeg
Git clone git: // source.ffmpeg.org/ffmpeg.git ffmpeg

(2) x264 <pre name = "code" class = "plain"> <pre name = "code" class = "plain"> git clone git: // git.videolan.org/x264.git

(3) x265hg clone https://bitbucket.org/multicoreware/x265

(4) yasm
Yasm is an assembly optimizer on the x86 platform. It can accelerate compilation of ffmpeg x264.
Wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
Tar xzvf yasm-1.3.0.tar.gz

3. Compile

3.1 configure the compilation Output Folder
Export FFMPEG_PATH = "YOUR_PATH"
Export PATH = "$ FFMPEG_PATH/bin: $ PATH"
For example, the output folder is $ HOME/ffmpeg_2.6.3/build_out.
So:
Export FFMPEG_PATH = "$ HOME/ffmpeg_2.6.3/build_out"

3.1 yasm
Cd yasm-1.3.0
./Configure -- prefix = "$ HOME /"
Make
Make install

Or install an existing library (yasm version ≥ 1.3.0)
Sudo apt-get install yasm

3.2x264

Add -- enable-gpl and -- enable-libx264 When configuring ffmpeg config
Cd x264 *
./Configure -- prefix = "$ FFMPEG_PATH" -- enable-shared -- enable-static
Make-j4
Make install
Make clean
Or install the existing library (yasm version ≥ 1.3.0) sudo apt-get install libx264-dev

3.3x265
Cd x265/build/linux
Cmake-G "Unix Makefiles"-DCMAKE_INSTALL_PREFIX = "$ FFMPEG_PATH"-DENABLE_SHARED: bool = off.../source
Make-j4
Make install
Make clean
</Tt> </span>

3.4 aac

Add -- enable-libfdk_aac When configuring ffmpeg config (assuming that -- enable-gpl is enabled at the same time -- enable-nonfree)
PKG_CONFIG_PATH = "$ FFMPEG_PATH/lib/pkgconfig"./configure \
-- Prefix = "$ FFMPEG_PATH "\
-- Pkg-config-flags = "-- static "\
-- Extra-cflags = "-I $ FFMPEG_PATH/include "\
-- Extra-ldflags = "-L $ FFMPEG_PATH/lib "\
-- Enable-gpl \
-- Enable-libass \
-- Enable-libfaac \
-- Enable-libfreetype \
Enable-libmp3lame \
-- Enable-libtheora \
-- Enable-libvorbis \
Enable-libx264 \
Enable-libx265 \
-- Enable-nonfree \
-- Enable-shared \
-- Enable-postproc \
Enable-x11grab \
-- Enable-bzlib \
-- Enable-libxvid \
-- Enable-zlib \
-- Disable-debug

4. Add ffmpeg to the Environment Variable

4.1 Add ffmpeg to Environment Variables
Vim ~ /. Bashrc
Add at last

Export FFMPEG_PATH = "/home/guohe/workspace/ffmpeg_2.6.3/build_out"
Export PATH = "$ FFMPEG_PATH/bin: $ PATH"

4.2 join the Linked database

When ffmpeg is called after compilation, error while loading shared libraries: xxx may occur.

There are two ways to solve this problem:

(1) Change/etc/ld. so. conf
Vim/etc/ld. so. conf

Add $ FFMPEG_PATH/lib at the end

Then run
Sudo ldconfig

(2) Change LD_LIBRARY_PATH

Vim ~ /. Bashrc
Add export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: $ FFMPEG_PATH/ib

Compile FFmpeg in Linux to download and compile the source file

Linux compiling and upgrading FFmpeg

Install FFMPEG on CentOS 5.6

Install FFmpeg in Ubuntu

Compile ffmpeg in Ubuntu 12.04

Install FFmpeg 2.2.2 In PPA in Ubuntu 14.04

FFmpeg details: click here
FFmpeg: click here

This article permanently updates the link address:

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.