起因 自学视音频编解码,先从FFmpeg
开始。本文记录下载、编译、安装FFmpeg
的全过程。
下载编译安装 下载 命令
1 git clone https://git.ffmpeg.org/ffmpeg.git
配置,编译FFmpeg
另外,可以根据./configure --help
命令来查看关于FFMPEG的配置参数。
接着我们就可以在ffmpeg_install
这个文件夹下看到如下目录
1 2 3 4 5 . ├── bin ├── include ├── lib ├── share
在bin
目录下执行这条命令
1 2 3 4 ./ffmpeg 报错 ./ffmpeg: error while loading shared libraries: libavdevice.so.57: cannot open shared object file: No such file or directory
系统提示找不到动态库,我们用ldd ffmpeg
命令看看运行当前可执行文件需要哪些动态库
1 2 3 4 5 6 7 8 9 10 11 12 13 $ ldd ffmpeg linux-vdso.so.1 (0x00007ffdf7584000) libavdevice.so.58 => not found libavfilter.so.7 => not found libavformat.so.58 => not found libavcodec.so.58 => not found libswresample.so.3 => not found libswscale.so.5 => not found libavutil.so.56 => not found libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc3e2f66000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc3e2d47000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc3e2956000) /lib64/ld-linux-x86-64.so.2 (0x00007fc3e3546000)
6,配置环境变量 1 $ export LD_LIBRARY_PATH=lib/
在./ffmpeg_install/bin
目录下运行
1 $ export LD_LIBRARY_PATH=../lib/
此时我们再运行ldd ffmpeg
命令查看
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 $ ldd ffmpeg linux-vdso.so.1 (0x00007ffc701f7000) libavdevice.so.58 => ../lib/libavdevice.so.58 (0x00007f0f70b9c000) libavfilter.so.7 => ../lib/libavfilter.so.7 (0x00007f0f7068f000) libavformat.so.58 => ../lib/libavformat.so.58 (0x00007f0f70233000) libavcodec.so.58 => ../lib/libavcodec.so.58 (0x00007f0f6eb0b000) libswresample.so.3 => ../lib/libswresample.so.3 (0x00007f0f6e8ee000) libswscale.so.5 => ../lib/libswscale.so.5 (0x00007f0f6e663000) libavutil.so.56 => ../lib/libavutil.so.56 (0x00007f0f6e23e000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0f6dea0000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0f6dc81000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0f6d890000) libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f0f6d668000) libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f0f6d465000) libxcb-shape.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shape.so.0 (0x00007f0f6d261000) libxcb-xfixes.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007f0f6d059000) libasound.so.2 => /usr/lib/x86_64-linux-gnu/libasound.so.2 (0x00007f0f6cd52000) libva.so.2 => /usr/lib/x86_64-linux-gnu/libva.so.2 (0x00007f0f6cb31000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0f6c914000) libva-drm.so.2 => /usr/lib/x86_64-linux-gnu/libva-drm.so.2 (0x00007f0f6c711000) libvdpau.so.1 => /usr/lib/x86_64-linux-gnu/libvdpau.so.1 (0x00007f0f6c50d000) libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f0f6c1d5000) /lib64/ld-linux-x86-64.so.2 (0x00007f0f70ff2000) libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f0f6bfd1000) libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f0f6bdcb000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0f6bbc7000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0f6b9bf000) libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007f0f6b7ae000) libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f0f6b59c000) libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f0f6b387000)
然后再去运行bin
目录下的ffmpeg
可执行文件
1 2 3 4 5 6 7 8 9 10 11 12 13 $ ./ffmpeg ffmpeg version N-95621-g53c21c2d6b Copyright (c) 2000-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1) configuration: --prefix=/home/zoctopus/sofoware/ffmpeg-src/ffmpeg_install --enable-shared --disable-static --disable-doc libavutil 56. 35.101 / 56. 35.101 libavcodec 58. 60.100 / 58. 60.100 libavformat 58. 33.100 / 58. 33.100 libavdevice 58. 9.100 / 58. 9.100 libavfilter 7. 66.100 / 7. 66.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
默认文件位置:
默认安装在/user/local文件下,其中:
头文件在/usr/local/include目录下
编译好的libs放在/usr/local/lib目录下
可执行文件放在/usr/local/bin目录下(ffmpeg、ffprobe、ffserver)
文档放在/usr/local/share/man/man1目录下
参考文章