文章目录
最开始需要安装相关依赖库
$ apt-get install build-essential git-core checkinstall yasm texi2html
$ apt-get install libvorbis-dev libx11-dev libvpx-dev libxfixes-dev zlib1g-dev pkg-config
$ apt-get install netcat libncurses5-dev
一、使用wget下载ffmpeg4.4安装包
$ wget http://ffmpeg.org/releases/ffmpeg-4.4.tar.bz2
二、解压
$ tar jxvf ffmpeg-4.4.tar.bz2
三、进入解压后生成的ffmpeg-4.4文件夹
四、运行configure文件
./configure --enable-shared --enable-swscale --enable-gpl --enable-nonfree --enable-pic --enable-version3 --enable-postproc --enable-pthreads --enable-static --enable-libvorbis --enable-libvpx
五、编译
make -j8
六、安装
make install
七、检查是否安装成功
ffmpeg -version
如出现类似于下列的情况,证明安装成功:
ffmpeg -version
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --enable-version3 --enable-postproc --enable-libvorbis --enable-libvpx
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
如出现下列情况,证明有问题:
./ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory
解决方法如下:
1、通过ldd ffmpeg
命令查找缺少的库
$ldd ffmpeg
linux-vdso.so.1 (0x0000fffc106b0000)
libavdevice.so.58 => not found
libavfilter.so.7 => not found
libavformat.so.58 => not found
libavcodec.so.58 => not found
libpostproc.so.55 => not found
libswresample.so.3 => not found
libswscale.so.5 => not found
libavutil.so.56 => not found
libm.so.6 => /lib64/libm.so.6 (0x0000fffc105b0000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000fffc10570000)
libc.so.6 => /lib64/libc.so.6 (0x0000fffc103e0000)
/lib/ld-linux-aarch64.so.1 (0x0000fffc106c0000)
2、使用find命令查找库
# find / -name 'libavdevice.so.58'
/root/ffmpeg-4.3/libavdevice/libavdevice.so.58
/home/ffmpeg/lib/libavdevice.so.58
第三行是指安装包里的so文件,不是我们要的
第四行是指安装后生成的so文件位置,是我们想要的
3、引用相关目录
在/etc/profile文件中的最后增加如下内容
export LD_LIBRARY_PATH=/home/ffmpeg/lib/
保存后退出,在终端输入命令:
# source /etc/profile
最后再次输入ffmpeg -version,提示安装成功
问题解决。
八、如何编译用到ffmpeg的程序
1、找到ffmpeg对应的所有.h文件,一般在/usr/local/include中,将其复制到你的程序目录下,可用一个include文件夹装起来后一起复制到程序目录,如下图
2、找到ffmpeg对应的所有.a .so文件,一般在/usr/local/lib中(找不到的话,可以用find / -name搜索),将其复制到你的程序目录下,可用一个lib文件夹装起来后一起复制到程序目录,如下图
编写对应的cmake,编译 执行