如何在 CentOS 8 上安装 FFmpeg | 少将全栈
  • 欢迎访问少将全栈,学会感恩,乐于付出,珍惜缘份,成就彼此、推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 吐槽,投稿,删稿,交个朋友
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏少将全栈吧

如何在 CentOS 8 上安装 FFmpeg

开发笔记 admin 4年前 (2021-05-27) 4224次浏览 已收录 扫描二维码

CentOS7 安装ffmpeg
自带的yum库不包含ffmpeg软件包,借助第三方YUM源下载ffmpeg
1.升级yum,安装Nux Dextop Yum 源
sudo yum install epel-release -y
sudo yum update -y
sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
2.安装FFmpeg 和 FFmpeg开发包
sudo yum install ffmpeg ffmpeg-devel -y
3.测试
ffmpeg

现在用的Centos8,那么CentOS8怎么安装ffmpeg?

同样CentOS 8 源仓库中也没有提供。

可以选择通过源文件编译安装 FFmpeg,或者使用dnf工具从Negativo17源仓库中安装。

1.Negativo17软件源依赖EPEL 和 PowerTools 软件源。

sudo dnf install epel-release
sudo yum config-manager --set-enabled PowerTools
sudo yum config-manager --add-repo=https://negativo17.org/repos/epel-multimedia.repo

2.一旦软件源被启用,安装FFmpeg:

sudo dnf install ffmpeg

3.通过检测版本号,验证FFmpeg安装:

ffmpeg -version

[root@centos Debug]# ffmpeg
ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (GCC)
configuration: --arch=x86_64 --bindir=/usr/bin --datadir=/usr/share/ffmpeg --disable-debug --disable-static --disable-stripping --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-alsa --enable-bzlib --enable-chromaprint --enable-decklink --enable-frei0r --enable-gcrypt --enable-gmp --enable-gnutls --enable-gpl --enable-gray --enable-iconv --enable-ladspa --enable-libass --enable-libaom --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdc1394 --enable-libdav1d --enable-libdavs2 --enable-libdrm --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libilbc --enable-libjack --enable-libkvazaar --enable-liblensfun --enable-libmodplug --enable-libmp3lame --enable-libndi_newtek --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-librtmp --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxcb --enable-libxcb-shape --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-lzma --enable-nonfree --enable-openal --enable-opencl --enable-opengl --enable-postproc --enable-sdl2 --enable-shared --enable-swresample --enable-swscale --enable-vaapi --enable-version3 --enable-vdpau --enable-xlib --enable-zlib --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --prefix=/usr --shlibdir=/usr/lib64 --enable-libzmq --enable-vapoursynth --enable-cuda --enable-cuvid --enable-ffnvcodec --enable-libmfx --enable-libnpp --enable-libsvtav1 --enable-libsvthevc --enable-libsvtvp9 --enable-libvmaf --enable-nvdec --enable-nvenc --extra-cflags=-I/usr/include/cuda --cpu=x86_64
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
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

FFmpeg已经安装OK。接下来运行

ffmpeg -re -i "001.mp4" -vcodec h264 -acodec aac -f rtp_mpegts rtp://127.0.0.1:10000

如下:

[root@centos ~]# ffmpeg -re -i "001.mp4" -vcodec h264 -acodec aac -f rtp_mpegts rtp://127.0.0.1:10000
ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (GCC)
configuration: --arch=x86_64 --bindir=/usr/bin --datadir=/usr/share/ffmpeg --disable-debug --disable-static --disable-stripping --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-alsa --enable-bzlib --enable-chromaprint --enable-decklink --enable-frei0r --enable-gcrypt --enable-gmp --enable-gnutls --enable-gpl --enable-gray --enable-iconv --enable-ladspa --enable-libass --enable-libaom --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdc1394 --enable-libdav1d --enable-libdavs2 --enable-libdrm --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libilbc --enable-libjack --enable-libkvazaar --enable-liblensfun --enable-libmodplug --enable-libmp3lame --enable-libndi_newtek --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-librtmp --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxcb --enable-libxcb-shape --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-lzma --enable-nonfree --enable-openal --enable-opencl --enable-opengl --enable-postproc --enable-sdl2 --enable-shared --enable-swresample --enable-swscale --enable-vaapi --enable-version3 --enable-vdpau --enable-xlib --enable-zlib --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --prefix=/usr --shlibdir=/usr/lib64 --enable-libzmq --enable-vapoursynth --enable-cuda --enable-cuvid --enable-ffnvcodec --enable-libmfx --enable-libnpp --enable-libsvtav1 --enable-libsvthevc --enable-libsvtvp9 --enable-libvmaf --enable-nvdec --enable-nvenc --extra-cflags=-I/usr/include/cuda --cpu=x86_64
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
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '001.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Duration: 00:00:06.00, start: 0.000000, bitrate: 2202 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 704x576, 2200 kb/s, 20 fps, 20 tbr, 10240 tbn, 40 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x21f6000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x21f6000] profile High, level 3.0, 4:2:0, 8-bit
Output #0, rtp_mpegts, to 'rtp://127.0.0.1:10000':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Stream #0:0(und): Video: h264 (libx264), yuv420p, 704x576, q=-1--1, 20 fps, 90k tbn, 20 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 120 fps= 17 q=28.0 Lsize= 1370kB time=00:00:05.85 bitrate=1917.8kbits/s speed=0.813x
video:1290kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.154413%
[libx264 @ 0x21f6000] frame I:1 Avg QP:23.52 size: 45061
[libx264 @ 0x21f6000] frame P:66 Avg QP:24.01 size: 14766
[libx264 @ 0x21f6000] frame B:53 Avg QP:27.67 size: 5689
[libx264 @ 0x21f6000] consecutive B-frames: 32.5% 16.7% 27.5% 23.3%
[libx264 @ 0x21f6000] mb I I16..4: 12.2% 39.9% 47.9%
[libx264 @ 0x21f6000] mb P I16..4: 2.7% 7.1% 4.2% P16..4: 44.2% 9.1% 6.2% 0.0% 0.0% skip:26.5%
[libx264 @ 0x21f6000] mb B I16..4: 0.6% 1.1% 1.5% B16..8: 52.2% 5.8% 1.7% direct: 2.2% skip:34.9% L0:58.6% L1:32.5% BI: 8.9%
[libx264 @ 0x21f6000] 8x8 transform intra:47.4% inter:32.8%
[libx264 @ 0x21f6000] coded y,uvDC,uvAC intra: 74.8% 33.5% 6.1% inter: 23.3% 8.3% 0.5%
[libx264 @ 0x21f6000] i16 v,h,dc,p: 17% 22% 20% 40%
[libx264 @ 0x21f6000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 15% 25% 6% 5% 7% 4% 9% 6%
[libx264 @ 0x21f6000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 24% 16% 7% 4% 5% 4% 6% 5%
[libx264 @ 0x21f6000] i8c dc,h,v,p: 58% 19% 21% 3%
[libx264 @ 0x21f6000] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x21f6000] ref P L0: 82.4% 9.5% 6.5% 1.7%
[libx264 @ 0x21f6000] ref B L0: 95.4% 4.1% 0.4%
[libx264 @ 0x21f6000] ref B L1: 98.6% 1.4%
[libx264 @ 0x21f6000] kb/s:1761.49

运行后,查看 ZLMediaKit 项目会有类似这样的日志

2021-05-27 18:01:04.141 I MediaServer[276207-140096188217088] MediaSource.cpp:402 emitEvent | 媒体注册:rtsp __defaultVhost__ rtp 88EFF7D7
2021-05-27 18:01:04.165 I MediaServer[276207-140096188217088] MediaSource.cpp:402 emitEvent | 媒体注册:rtmp __defaultVhost__ rtp 88EFF7D7
2021-05-27 18:01:04.165 I MediaServer[276207-140096188217088] MediaSource.cpp:402 emitEvent | 媒体注册:ts __defaultVhost__ rtp 88EFF7D7
2021-05-27 18:01:04.244 I MediaServer[276207-140096188217088] MediaSource.cpp:402 emitEvent | 媒体注册:fmp4 __defaultVhost__ rtp 88EFF7D7
2021-05-27 18:01:24.244 W MediaServer[276207-140096188217088] MediaSource.cpp:547 operator() | 无人观看事件:fmp4/__defaultVhost__/rtp/88EFF7D7
2021-05-27 18:01:25.066 W MediaServer[276207-140096188217088] RtpSelector.cpp:109 onManager | RtpProcess timeout:88EFF7D7
2021-05-27 18:01:25.066 W MediaServer[276207-140096188217088] RtpProcess.cpp:48 ~RtpProcess | 88EFF7D7(127.0.0.1:47772) RTP推流器(__defaultVhost__/rtp/88EFF7D7)断开,耗时(s):5
2021-05-27 18:01:25.066 I MediaServer[276207-140096188217088] MediaSource.cpp:402 emitEvent | 媒体注销:fmp4 __defaultVhost__ rtp 88EFF7D7

喜欢 (3)
[🍬谢谢你请我吃糖果🍬🍬~]
分享 (0)
关于作者:
少将,关注Web全栈开发、项目管理,持续不断的学习、努力成为一个更棒的开发,做最好的自己,让世界因你不同。