ffmpeg ffplay的编译方法

最近想研究学习一下ffmpeg,发现用ffmpeg-4.0版本编译出来的没有ffplay播放器,试了网上的各种方法,还是报错,由于SDL安装的是1.x版本,所以怀疑ffmpeg-4.0需要匹配SDL2.x版本。

下载了比较老的ffmpeg-2.2.16版本,成功编译了ffplay并运行,记录一下步骤。

由于我的ubuntu是root用户,命令中的sudo省略。

step1.安装yasm

apt-get install yasm

step2.安装SDL

如果不安装SDL的话编译会报SDL.h找不到的问题

apt-get install libsdl1.2-dev

apt-get install libsdl-image1.2-dev

apt-get install libsdl-ttf2.0-dev

apt-get install libsdl-gfx1.2-dev

step3.下载ffmpeg-2.2.16版本

网址:https://www.ffmpeg.org/

解压:tar zxvf ffmpeg-2.2.16.tar.gz

cd ffmpeg-2.2.16

./configure --enable-shared --prefix=./out

vim config.mak确保line 544为:CONFIG_FFPLAY=yes(ffplay4.0版本默认前面有!)

make;make install

step4.问题处理

进到out目录的bin下面发现已经有ffplay了,但是./ffplay -version报错:

./ffplay: error while loading shared libraries: libavdevice.so.55: cannot open shared object file: No such file or directory

利用find -name "libavdevice.so.55"可以查到该库就在out目录下的lib中

错误原因是系统没有找到这个库

vim /etc/ld.so.conf

加一句:/ffmpeg2.2/ffmpeg-2.2.16/out/lib

保存退出后ldconfig使配置生效

step5.ffplay播放

这时ffplay可以正常使用

./ffplay -autoexit /stream/test.mp4 即可正常播放

【参考博客】

https://www.cnblogs.com/freeweb/p/6897907.html

https://blog.csdn.net/Riven_mingri/article/details/53409234

https://blog.csdn.net/yihui8/article/details/12016077

猜你喜欢

转载自blog.csdn.net/liaojunwu/article/details/80425593