选择要安装的版本进行下载即可。
也可以通过git命令进行下载,方法如下:
- # git clone https://code.videolan.org/videolan/x264.git
-
说明:如果需要视频转码必须要先安装libx264,否则会转码失败
- [root@172-16-8-145 ~]# tar -zxvf x264.tar.gz
-
- [root@172-16-8-145 x264]# ./configure --enable-shared
- [root@172-16-8-145 x264]# make
-
- [root@172-16-8-145 x264]# make install
-
- [root@172-16-8-145 x264]# x264 --version
- x264 0.161.3048 b86ae3c
- built on Feb 18 2021, gcc: 7.3.0
- x264 configuration: --chroma-format=all
- libx264 configuration: --chroma-format=all
- x264 license: GPL version 2 or later
- [root@172-16-8-145 x264]#
-
能正确显示版本号说明安装成功。
- tar -zxvf ffmpeg-4.3.tar.gz
-
- [root@172-16-8-145 ffmpeg-4.3]# ./configure --enable-shared --enable-swscale --enable-gpl --enable-nonfree --enable-pic --prefix=/home/ffmpeg --enable-version3 --enable-postproc --enable-pthreads --enable-static --enable-libx264
- [root@172-16-8-145 ffmpeg-4.3]# make
-
必须先安装libx264,否则这步会报错,缺少libx264的库
- [root@172-16-8-145 ffmpeg-4.3]# make install
-
在/etc/profile文件最后增加如下内容
- export ffmpeg_home=/home/ffmpeg
- export PATH=${ffmpeg_home}/bin:$PATH
-
然后通过source使配置文件生效即可。
- [root@172-16-8-145 bin]# ffmpeg --version
- ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers
- built with gcc 7.3.0 (GCC)
- configuration: --enable-shared --enable-swscale --enable-gpl --enable-nonfree --enable-pic --prefix=/home/ffmpeg --enable-version3 --enable-postproc --enable-pthreads --enable-static --enable-libx264
- libavutil 56. 51.100 / 56. 51.100
- libavcodec 58. 91.100 / 58. 91.100
- libavformat 58. 45.100 / 58. 45.100
- libavdevice 58. 10.100 / 58. 10.100
- libavfilter 7. 85.100 / 7. 85.100
- libswscale 5. 7.100 / 5. 7.100
- libswresample 3. 7.100 / 3. 7.100
- libpostproc 55. 7.100 / 55. 7.100
- Unrecognized option '-version'.
- Error splitting the argument list: Option not found
- [root@172-16-8-145 bin]#
-
能正常显示版本号说明安装成功。
问题现象:
- [root@172-16-8-145 bin]# ./ffmpeg --version
- ./ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory
-
排查过程:
- [root@172-16-8-145 bin]# 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)
- [root@172-16-8-145 bin]#
-
- [root@172-16-8-145 bin]# find / -name 'libavdevice.so.58'
- /root/ffmpeg-4.3/libavdevice/libavdevice.so.58
- /home/ffmpeg/lib/libavdevice.so.58
- [root@172-16-8-145 bin]#
-
从上面的结果可以说明libavdevice.so.58库在root和home目录下,这样我们把这个目录引用一下就可以了
在/etc/profile文件中的最后增加如下内容
- export LD_LIBRARY_PATH=/home/ffmpeg/lib/
-
然后使文件生效
- [root@172-16-8-145 bin]# source /etc/profile
-
这样问题就解决了。