本篇内容介绍了“linux安装ffmpeg的详细步骤”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
#!/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
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
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
2.安装相关依赖类
需要用到的依赖库是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个程序中用到.
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=http://www.yisu.com/usr \
--disable-static \
--docdir=http://www.yisu.com/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=http://www.yisu.com/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=http://www.yisu.com/usr --disable-static &&
make
If you wish to run the tests, issue: make check.
Now, as the root user:
make install
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。