Linux安装ffmpeg

安装yasm

#ffmpeg configure期间,报错缺少nasm或者yasm,初始化中断
nasm/yasm not found .......................

进入网站,找到最新版的yasm的tar.gz的文件,点击下载

http://www.tortall.net/projects/yasm/releases/

解压之后,进入目录

$ ./configure
$ make
$ sudo make install

安装x264库

ffmpeg的h264转码需要这个库
x264, the best H.264/AVC encoder - VideoLAN

$ git clone https://code.videolan.org/videolan/x264.git
$ cd x264
$ sudo apt install nasm
$ ./configure --enable-shared --enable-static
#需要使能动态库\静态库,否则只会生成x264的可执行文件
$ make
$ sudo make install
#成功后会打印各个文件的安装路径

安装ffmpeg

https://ffmpeg.org/
进入官网,下周Source Code源码
解压

$ ./configure --enable-shared --enable-swscale --enable-gpl --enable-nonfree --enable-pic --enable-version3 --enable-postproc --enable-pthreads --enable-static --enable-libx264
#使能x264必须也要使能gpl
$ make
$ sudo make install

遇到的问题

$ ffmpeg -version
ffmpeg: error while loading shared libraries: libavdevice.so.59: cannot open shared object file: No such file or directory
#查看依赖
$ ldd ffmpeg
        linux-vdso.so.1 (0x00007ffc6c2ae000)
        libavdevice.so.59 => not found
        libavfilter.so.8 => not found
        libavformat.so.59 => not found
        libavcodec.so.59 => not found
        libpostproc.so.56 => not found
        libswresample.so.4 => not found
        libswscale.so.6 => not found
        libavutil.so.57 => not found
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5adb01b000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5adaff8000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5adae06000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f5adb1cb000)
#查找库
$ find /usr -name 'libavdevice.so.59'
/usr/local/lib/libavdevice.so.59
#然后可以将这个路径添加到环境变量里
export LD_LIBRARY_PATH=/usr/local/lib/

参考:https://www.cnblogs.com/comexchan/p/12079333.html

posted @ 2022-12-08 23:28  WuYunTaXue  阅读(457)  评论(0编辑  收藏  举报