下载软件

#!/bin/bash

# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377

# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev

# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
sudo apt-get -y install build-essential checkinstall git libfaac-dev libgpac-dev \
  libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev librtmp-dev libtheora-dev \
    libvorbis-dev pkg-config texi2html yasm zlib1g-dev

# Install x264
sudo apt-get -y install libx264-dev
cd
git clone --depth 1 git://git.videolan.org/x264
cd x264
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
  awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
    --fstrans=no --default

# Install AAC audio decoder
cd
wget http://downloads.sourceforge.net/opencore-amr/fdk-aac-0.1.0.tar.gz
tar xzvf fdk-aac-0.1.0.tar.gz
cd fdk-aac-0.1.0
./configure
make
sudo checkinstall --pkgname=fdk-aac --pkgversion="0.1.0" --backup=no \
  --deldoc=yes --fstrans=no --default

# Install VP8 video encoder and decoder.
cd
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx 
cd libvpx
./configure
make
sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no \
  --deldoc=yes --fstrans=no --default


# Add lavf support to x264
# This allows x264 to accept just about any input that FFmpeg can handle and is useful if you want to use x264 directly. See a more detailed explanation of what this means.
cd ~/x264
make distclean
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
  awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
  --fstrans=no --default
#downloaded rtmpdump
http://rtmpdump.mplayerhq.hu/
git clone git://git.ffmpeg.org/rtmpdump
cd rtmpdump
为了得到调试信息,这里简单修改一下文件夹rtmpdump和librtmp的Makefile文件,添加-g参数,注意去掉优化参数-O2那项

在rtmpdump的Makefile中的

OPT=-O2

CFLAGS=-Wall -g $(XCFLAGS) $(INC) $(DEF) $(OPT)

在librtmp的Makefile中的

CFLAGS=-Wall ....  -g

安装相关依赖类

需要用到的依赖库是zlib, openssl库,使用如下命令安装

sudo apt-get install openssl 
sudo apt-get install libssl-dev
sudo apt-get install zlib1g-dev

可以先查看可用的安装包

sudo apt-cache search openssl

通过阅读Makefile文件,我发现rtmpdump需要引用的动态库如下

-lz -lssl -lcrypto -lrtmp -lpthread

make后会生成4个可执行文件, 分别是rtmpdump,rtmpsvr, rtmpsuck, rtmpgw, 其中pthread直会在rtmpsvr, rtmpsuck, rtmpgw这3个程序中用到.

编译安装

make
sudo make install

首先要保证相关库已经成功安装到/usr/local/lib下面
再要保证/usr/local/lib在/etc/ld.so.conf配置文件中,然后

sudo ldconfig

来更新动态库缓存
检查rtmpdump所有依赖库是否都引用成功

ldd rtmpdump
#downloaded libogg
wget https://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz
Installation of libogg

Install libogg by running the following commands:

./configure --prefix=/usr    \
            --disable-static \
            --docdir=/usr/share/doc/libogg-1.3.2 &&
make
To test the results, issue: make check.

Now, as the root user:

make install
#downloaded libvorbis-1.3.5
wget https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz
Installation of libvorbis

Optionally fix installation of the package when --enable-docs is added to the configure switches:

sed -i '/components.png \\/{n;d}' doc/Makefile.in
Install libvorbis by running the following commands:

./configure --prefix=/usr --disable-static &&
make
To test the results, issue: make LIBS=-lm check.

Now, as the root user:

make install &&
install -v -m644 doc/Vorbis* /usr/share/doc/libvorbis-1.3.5

#downloaded libtheora

wget https://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.xz
Installation of libtheora

Install libtheora by running the following commands:

sed -i 's/png_\(sizeof\)/\1/g' examples/png2theora.c &&
./configure --prefix=/usr --disable-static &&
make
If you wish to run the tests, issue: make check.

Now, as the root user:

make install

# Installing FFmpeg
cd
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libfdk-aac --enable-libmp3lame 
--enable-libopencore-amrnb   --enable-libopencore-amrwb --enable-librtmp 
--enable-libtheora --enable-libvorbis     --enable-libvpx --enable-libx264 
--enable-nonfree --enable-version3 
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(date +%Y%m%d%H%M)-git" --backup=no \
  --deldoc=yes --fstrans=no --default
  hash x264 ffmpeg ffplay ffprobe

# Optional: install qt-faststart
# This is a useful tool if you're showing your H.264 in MP4 videos on the web. It relocates some data in the video to allow playback to begin before the file is completely downloaded. Usage: qt-faststart input.mp4 output.mp4.
cd ~/ffmpeg
make tools/qt-faststart
sudo checkinstall --pkgname=qt-faststart --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
  --deldoc=yes --fstrans=no --default install -Dm755 tools/qt-faststart \
  /usr/local/bin/qt-faststart

我用一段转码测试了一下

#ffmpeg -i file.avi output.flv  

发现报了一个库找不到的错
225536_4LyZ_2896194
去搜索了一下相关问题
225902_Nb1V_2896194
解决了

打赏
支付宝 微信
上一篇 下一篇