标签:
FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。采用LGPL或GPL许可证。它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的音频/视频编解码库libavcodec,为了保证高可移植性和编解码质量,libavcodec里很多codec都是从头开发的。最近在做一个实验,需要使用ffmpeg,花了很长时间在网络上进行查询安装,下面是详细的安装教程:
1、lame
lame-3.99.5.tar.gz
Url:http://sourceforge.net/project/showfiles.php?group_id=290&package_id=309
2、libogg
libogg-1.3.1.tar.gz
Url:http://www.xiph.org/downloads/
3、libvorbis
libvorbis-1.3.3.tar.gz
Url:http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
(libvorbis依赖于libogg, 所以libogg必须先于libvorbis安装)
安装方法如下:
xvidcore-1.3.2.tar.gz
Url:http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
5、x264
latest_x264.tar.bz2 (其中包含的目录是 x264-snapshot-20131023-2245)
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
(下载最新的版本安装就行)
安装方法
1、./configure --prefix=/usr/local/x264 --enable-shared --enable-static --enable-yasm
2、make
3、make install
6、libdts
libdca-0.0.5.tar.bz2
Url: http://www.videolan.org/developers/libdca.html
7、a52
a52dec-0.7.4.tar.gz (这个库从2002年就没有更新过了,我并没有能够打开连接,就没有安装这个解码器)
http://liba52.sourceforge.net/downloads.html
8、faad2
faad2-2.7.tar.gz
http://www.audiocoding.com/downloads.html
9、faac
faac-1.28.tar.gz
http://www.audiocoding.com/downloads.html
10、amr-nb
使用sudo apt-get install libopencore-amrwb-dev
安装
11、amr-wb
使用sudo apt-get install libopencore-amrwb-dev
安装
1 ./configure --prefix=/usr/local/ffmpeg2 --enable-libmp3lame --enable-libvorbis --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libxvid --enable-postproc --enable-ffserver --enable-ffplay
2 make
3 make install
安装完成后在/usr/local/ffmpeg出现三个目录:
**bin:可执行文件目录
lib:动态链接库目录
include:编程用到的头文件目录**
不管是编程还是可执行程序的执行都需要依赖lib下面的动态库,可以把里面的so文件拷贝到/usr/lib下,但可以直接修改配置文件。通过查看/etc/ld.so.conf文件,发现里面只有一句话:include ld.so.conf.d/*.conf
表明其包含了ld.so.conf.d下所有的conf文件,于是可以在/etc/ld.so.conf.d/创建一个新的文件ffmpeg.conf,其中之包含一句话,即为ffmpeg的lib目录:
/usr/local/ffmpeg/lib
再执行ldconfig,更新ld.so.cache,使修改生效。
1. cd etc/ld.so.conf.d/
2. sudo gedit ffmpeg.conf
3. 在ffmpeg上添加/usr/local/ffmpeg/lib
4.ldconfig
为了在任何地方能够直接用ffmpeg运行,而不需要
使用如./ffmpeg或者 /usr/local/ffmpeg/bin/ffmpeg的方式运行程序,可以把可执行程序复制到bin目录下,这里选择在bin目录下创建软链接。软链接类似于Windows下的快捷方式,如果原可执行程序被删除了,软链接也不能继续使用,而硬链接则可以继续使用。创建链接命令如下:
(在usr/local下找到自己的ffmpeg文件夹,名字可能会略有不同)
1. sudo ln -s /usr/local/ffmpeg/bin/ffmpeg /usr/local/bin/
2. sudo ln -s /usr/local/ffmpeg/bin/ffprobe /usr/local/bin/
3. sudo ln -s /usr/local/ffmpeg/bin/ffserver /usr/local/bin/
现在可以在shell中直接输入ffmpeg运行程序,得到以下结果:
[noalgo@NOALGO ~]$ ffmpeg
ffmpeg version 2.5.3 Copyright (c) 2000-2015 the FFmpeg developers
built on Jan 14 2015 11:54:30 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
configuration: –enable-shared –prefix=/usr/local/ffmpeg
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.102 / 56. 15.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Use -h to get full help or, even better, run ‘man ffmpeg’
1、安装完成之后,运行ffmpeg,可能会出现:
ffmpeg: error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory
可以使用下面方法解决:
1. [root@host ~]# ldd $(which ffmpeg)
linux-vdso.so.1 => (0x00006efe6b90f000)
libavdevice.so.56 => not found
libavfilter.so.5 => not found
libavformat.so.56 => not found
libavcodec.so.56 => not found
libpostproc.so.53 => not found
libswresample.so.1 => not found
libswscale.so.3 => not found
libavutil.so.54 => not found
libm.so.6 => /lib64/libm.so.6 (0x00006efe6b67a000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00006efe6b45d000)
libc.so.6 => /lib64/libc.so.6 (0x00006efe6b0c8000)
/lib64/ld-linux-x86-64.so.2 (0x00006efe6b910000)
在上面的指令中,你可能会看到“not found”的信息,使用下面的指令来解决这个问题:
[root@host ~]# updatedb && locate libavdevice.so
/opt/ffmpeg/libavdevice/libavdevice.so
/opt/ffmpeg/libavdevice/libavdevice.so.56
/usr/local/lib/libavdevice.so
/usr/local/lib/libavdevice.so.56
/usr/local/lib/libavdevice.so.56.4.100
然后,执行ldconfig指令来装载该库文件。
最后,使用ldd来检查库文件:
[root@host ~]# ldd $(which ffmpeg)
linux-vdso.so.1 => (0x000068716560a000)
libavdevice.so.56 => /usr/local/lib/libavdevice.so.56 (0x00006871653e7000)
libavfilter.so.5 => /usr/local/lib/libavfilter.so.5 (0x000068716505b000)
libavformat.so.56 => /usr/local/lib/libavformat.so.56 (0x0000687164c77000)
libavcodec.so.56 => /usr/local/lib/libavcodec.so.56 (0x00006871636bb000)
libpostproc.so.53 => /usr/local/lib/libpostproc.so.53 (0x0000687163473000)
libswresample.so.1 => /usr/local/lib/libswresample.so.1 (0x0000687163257000)
libswscale.so.3 => /usr/local/lib/libswscale.so.3 (0x0000687162fc6000)
libavutil.so.54 => /usr/local/lib/libavutil.so.54 (0x0000687162d5f000)
libm.so.6 => /lib64/libm.so.6 (0x0000687162ada000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00006871628bd000)
libc.so.6 => /lib64/libc.so.6 (0x0000687162529000)
libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x000068716230a000)
libxcb-shm.so.0 => /usr/lib64/libxcb-shm.so.0 (0x0000687162108000)
libxcb-xfixes.so.0 => /usr/lib64/libxcb-xfixes.so.0 (0x0000687161f02000)
libxcb-shape.so.0 => /usr/lib64/libxcb-shape.so.0 (0x0000687161cfe000)
libasound.so.2 => /lib64/libasound.so.2 (0x0000687161a13000)
libz.so.1 => /lib64/libz.so.1 (0x00006871617fd000)
libx264.so.148 => /usr/local/lib/libx264.so.148 (0x0000687161443000)
libvpx.so.1 => /usr/lib64/libvpx.so.1 (0x00006871610b8000)
libvorbisenc.so.2 => /usr/lib64/libvorbisenc.so.2 (0x0000687160cde000)
libvorbis.so.0 => /usr/lib64/libvorbis.so.0 (0x0000687160ab1000)
libtheoraenc.so.1 => /usr/lib64/libtheoraenc.so.1 (0x0000687160884000)
libtheoradec.so.1 => /usr/lib64/libtheoradec.so.1 (0x0000687160675000)
libopencore-amrwb.so.0 => /usr/lib64/libopencore-amrwb.so.0 (0x000068716045e000)
libopencore-amrnb.so.0 => /usr/lib64/libopencore-amrnb.so.0 (0x000068716022f000)
libmp3lame.so.0 => /usr/lib64/libmp3lame.so.0 (0x000068715ffb8000)
libfaac.so.0 => /usr/lib64/libfaac.so.0 (0x000068715fda5000)
librt.so.1 => /lib64/librt.so.1 (0x000068715fb9d000)
/lib64/ld-linux-x86-64.so.2 (0x000068716560b000)
libXau.so.6 => /usr/lib64/libXau.so.6 (0x000068715f999000)
libdl.so.2 => /lib64/libdl.so.2 (0x000068715f795000)
libogg.so.0 => /usr/lib64/libogg.so.0 (0x000068715f58e000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x000068715f288000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x000068715f072000)
参考网站:
http://www.cnblogs.com/wanghetao/p/3386311.html
http://noalgo.info/874.html
http://blog.csdn.net/season_hangzhou/article/details/24399371
https://www.servermanagementadmins.com/ffmpeg-error-while-loading-shared-libraries-libavdevice-so-56-cannot-open-shared-object-file-no-such-file-or-directory/
标签:
原文地址:http://blog.csdn.net/u013057233/article/details/51351267