Ubuntu16.04安装编译ffmpeg

本文主要基于此官方指导编译

1. 安装依赖

sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev
mkdir ~/ffmpeg_sources  //根目录下创建文件夹
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

2. Compilation & Installation

Yasm

sudo apt-get install yasm
  • 1
  • 1

libx264

sudo apt-get install libx264-dev
  • 1
  • 1

libx265

sudo apt-get install cmake mercurial
cd ~/ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install
make distclean
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

libfdk-aac

cd ~/ffmpeg_sources
wget -O fdk-aac.tar.gz https://github.com/mstorsjo/fdk-aac/tarball/master
tar xzvf fdk-aac.tar.gz
cd mstorsjo-fdk-aac*
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

libmp3lame

sudo apt-get install libmp3lame-dev
  • 1
  • 1

libopus

sudo apt-get install libopus-dev
  • 1
  • 1

libvpx

cd ~/ffmpeg_sources
wget http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.5.0.tar.bz2
tar xjvf libvpx-1.5.0.tar.bz2
cd libvpx-1.5.0
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests
PATH="$HOME/bin:$PATH" make
make install
make clean
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

avdevice

sudo apt-get install libavdevice-dev
  • 1
  • 1

ffmpeg

cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" 
  
./configure --prefix=”$HOME/ffmpeg_build” --pkg-config-flags="--static"  --extra-cflags="-I$HOME/ffmpeg_build/include"   --extra-ldflags="-L$HOME/ffmpeg_build/lib"   --bindir="$HOME/bin"  --enable-gpl   --enable-libass   --enable-libfdk-aac   --enable-libfreetype   --enable-libmp3lame   --enable-libopus   --enable-libtheora   --enable-libvorbis   --enable-libvpx  --enable-libx264   --enable-libx265   --enable-nonfree
PATH="$HOME/bin:$PATH" makemake installmake distcleanhash -r
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
 
  

到这里ffmpeg就编译安装结束了,编译过的ffmpeg在~/bin 目录下

Usage

两种方法使用ffmpeg

  • 进入~/bin文件夹,然后调用binary文件: cd ~/bin && ./ffmpeg -i ~/input.mp4 ~/videos/output.mkv
  • 使用绝对路径:/home/yourusername/bin/ffmpeg -i ../input.mp4 ../videos/output.mkv

如果想要ffmpeg在所有地方都能直接调用,需要先注销,然后登陆。 
或者执行source ~/.profile

Documentation

如果想要用man ffmpeg命令看文档,执行下面命令

echo "MANPATH_MAP $HOME/bin $HOME/ffmpeg_build/share/man" >> ~/.manpath
  • 1
  • 1

注销,然后登陆即可。

更新FFmpeg

rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffplay,ffserver,vsyasm,x264,x265,yasm,ytasm}
  • 1
  • 1

然后从头开始再来一次



转自:http://blog.csdn.net/u012891472/article/details/51482460,略作修改

你可能感兴趣的:(视频编解码,H.265/HEVC,多媒体,毕业论文相关,H.264/AVC,环境搭建)