服务器上安装ffmpeg后报错及解决方案
问题描述
实习的时候要求复现从视频中提取3D骨架的论文,其中一篇源码中要用到ffmpeg来对视频进行预处理。安装完ffmpeg之后导入ffmpeg的时候出错,出错信息提示为:
libavdevice.so.58: cannot open shared object file: No such file or directory
解决方案
经过一番查找资料,找了很多方法,其中有一些方法没有解决我的问题,费了大半天的劲儿才解决了这个问题,在这里记录一下解决问题的过程。
首先来回忆一下安装ffmpeg过程中需要编译,编译指令为:
./configure --enable-shared --prefix=/monchickey/ffmpeg
make
make install
经过漫长的编译过程…好的,终于编译好了。
但是呢,导入ffmpeg的时候会提示无法打开libavdevice.so.58。这是因为lib路径没有加到系统库中,而系统ld目录列表在/etc/ld.so.conf中。在命令行中输入:
vim /etc/ld.so.conf.d/ffmpeg.conf
或者:
vi /etc/ld.so.conf.d/ffmpeg.conf
按i进入编辑模式,在最后一行添加lib路径:
/monchickey/ffmpeg/lib
按’esc:wq’保存修改并退出;然后执行 ldconfig 使配置生效。
查看ffmpeg信息如下:
username@ubuntu:~$ ffmpeg -version
ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609
configuration:
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
接下来就可以愉快地使用ffmpeg来编辑视频啦~