raspberry install ffmpeg

1、下载ffmpeg
下载网址:http://www.ffmpeg.org/download.html
2、解压缩
tar -zxvf ffmpeg-2.4.2.tar.gz
3、配置,生成Makefile
./configure –enable-shared –disable-yasm –prefix=/usr/local/ffmpeg
4、编译安装
make
sudo make install
5、安装之后在/usr/local/ffmpeg会看到有三个目录
bin 执行文件目录
lib 静态,动态链接库目录
include 编程用到的头文件
为了防止执行程序找不到库文件,
可以将/usr/local/ffmpeg/lib目录设置到LD_LIBRARY_PATH环境变量,
或者查看/usr/local/ffmpeg/lib下所有的链接,并在/usr/lib下建立同样的链接。如下。
ln -s /usr/local/ffmpeg/lib/libavcodec.so /usr/lib/libavcodec.so
ln -s /usr/local/ffmpeg/lib/libavdevice.so /usr/lib/libavdevice.so
ln -s /usr/local/ffmpeg/lib/libavfilter.so /usr/lib/libavfilter.so
ln -s /usr/local/ffmpeg/lib/libavformat.so /usr/lib/libavformat.so
ln -s /usr/local/ffmpeg/lib/libavutil.so /usr/lib/libavutil.so
ln -s /usr/local/ffmpeg/lib/libswresample.so /usr/lib/libswresample.so
ln -s /usr/local/ffmpeg/lib/libswscale.so /usr/lib/libswscale.so
ln -s /usr/local/ffmpeg/lib/libavcodec.so /usr/lib/libavcodec.so.56
ln -s /usr/local/ffmpeg/lib/libavdevice.so /usr/lib/libavdevice.so.56
ln -s /usr/local/ffmpeg/lib/libavfilter.so /usr/lib/libavfilter.so.5
ln -s /usr/local/ffmpeg/lib/libavformat.so /usr/lib/libavformat.so.56
ln -s /usr/local/ffmpeg/lib/libavutil.so /usr/lib/libavutil.so.54
ln -s /usr/local/ffmpeg/lib/libswresample.so /usr/lib/libswresample.so.1
ln -s /usr/local/ffmpeg/lib/libswscale.so /usr/lib/libswscale.so.3
6、编译测试程序
gcc -o ffmpegtest ffmpegtest.c -I/usr/local/ffmpeg/include -L/usr/local/ffmpeg/lib -lavformat -lavcodec -lavtuil
7、执行程序
./ffmpegtest
或直接执行/usr/local/ffmpeg/lib目录下的./ffmpeg进行测试。

 

 

ffmpeg: error while loading shared libraries: libavdevice.so.56:
cannot open shared object file: No such file or directory

此情况是因为ffmpeg未找到相关依赖包,可以通过以下方法解决
先 find / -name libavdevice.so.56 得到该文件的目录地址,
然后 vim /etc/ld.so.conf 将上述目录添加到最后一行并保存退出;
再 ldconfig 使配置生效,即可;

如果执行 ldconfig: command not found

export PATH=”$PATH:/sbin”

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.