我在 CentOS 8.4 上使用 ffmpeg 处理 RTMP/RTMPS 协议时遇到了困难。它在 CentOS 7 和 Debian 上运行良好,只是最新版本的 CentOS 出现了问题。我做错了什么吗?
静态构建
ffmpeg 的静态版本(主版本和稳定版本)在输入或输出中引用 rtmp 时会产生分段错误。我已在 Vultr 和 VirtualBox 中的新 VM 上使用最新的 CentOS 8 映像对此进行了测试。我曾尝试在 ffmpeg 错误跟踪器上报告此问题,但显然这不是正确的地方:https://trac.ffmpeg.org/ticket/9309
简单运行ffmpeg -i rtmp://localhost:1935/live/app
就会立即产生段错误。
从源代码编译
更新:RTMP 可以从这个编译版本运行,但是 RTMPS 出现“未找到协议”错误。
我尝试按照以下方法进行编译官方指南./configure “Enabled protocol”的结果中列出了“rtmp, rtmps”协议:
Enabled protocols:
async data ftp http md5 prompeg rtmpt srtp tls
cache ffrtmpcrypt gopher httpproxy mmsh rtmp rtmpte subfile udp
concat ffrtmphttp gophers https mmst rtmpe rtmpts tcp udplite
crypto file hls icecast pipe rtmps rtp tee unix
但是将流发布到 rtmps 地址的结果是“未找到协议”:
ffmpeg -i rtmp://localhost:19350/nginxrtmptest/nginxrtmptest -acodec copy -vcodec copy -tune zerolatency -f flv rtmps://live-api-s.facebook.com:443/rtmp/**REDACTED**
ffmpeg version N-102809-gde8e6e67e7 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 8 (GCC)
configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs=-lpthread --extra-libs=-lm --bindir=/root/bin --enable-gpl --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 57. 0.100 / 57. 0.100
libavcodec 59. 3.100 / 59. 3.100
libavformat 59. 3.101 / 59. 3.101
libavdevice 59. 0.100 / 59. 0.100
libavfilter 8. 0.103 / 8. 0.103
libswscale 6. 0.100 / 6. 0.100
libswresample 4. 0.100 / 4. 0.100
libpostproc 56. 0.100 / 56. 0.100
[h264 @ 0x332ed80] co located POCs unavailable
Last message repeated 1 times
Input #0, flv, from 'rtmp://localhost:19350/nginxrtmptest/nginxrtmptest':
Metadata:
|RtmpSampleAccess: true
Server : NGINX RTMP (github.com/sergey-dryabzhinsky/nginx-rtmp-module)
displayWidth : 1280
displayHeight : 720
fps : 30
videokeyframe_frequency: 0
profile :
level :
Duration: 00:00:00.00, start: 9.145000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 98 kb/s
Stream #0:1: Video: h264 (Constrained Baseline), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 1280 kb/s, 30 fps, 30 tbr, 1k tbn
rtmps://live-api-s.facebook.com:443/rtmp/**REDACTED**r: Protocol not found
构建脚本
我尝试过构建脚本https://github.com/markus-perl/ffmpeg-build-script然而,它在配置 libsdl 时失败,抱怨缺少 Xext.h (libxext-dev),尽管使用时找不到该包yum install libxext-dev
building libsdl
=======================
SDL2-2.0.14.tar.gz has already downloaded.
Extracted SDL2-2.0.14.tar.gz
$ ./configure --prefix=/root/ffmpeg-build-script/workspace --disable-shared --enable-static
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... gawk
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for windres... no
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... yes
checking for pkg-config... /root/ffmpeg-build-script/workspace/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for working volatile... yes
checking for GCC -MMD -MT option... yes
checking for linker option --no-undefined... yes
checking for linker option --dynamicbase... no
checking for linker option --nxcompat... no
checking for linker option --high-entropy-va... no
checking for ANSI C header files... (cached) yes
checking for sys/types.h... (cached) yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking for stdlib.h... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking stdarg.h usability... yes
checking stdarg.h presence... yes
checking for stdarg.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for memory.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking wchar.h usability... yes
checking wchar.h presence... yes
checking for wchar.h... yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking ctype.h usability... yes
checking ctype.h presence... yes
checking for ctype.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking float.h usability... yes
checking float.h presence... yes
checking for float.h... yes
checking iconv.h usability... yes
checking iconv.h presence... yes
checking for iconv.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for size_t... yes
checking for M_PI in math.h... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for working memcmp... yes
checking for working strtod... yes
checking for mprotect... yes
checking for malloc... yes
checking for calloc... yes
checking for realloc... yes
checking for free... yes
checking for getenv... yes
checking for setenv... yes
checking for putenv... yes
checking for unsetenv... yes
checking for qsort... yes
checking for abs... yes
checking for bcopy... yes
checking for memset... yes
checking for memcpy... yes
checking for memmove... yes
checking for wcslen... yes
checking for wcslcpy... no
checking for wcslcat... no
checking for wcsdup... yes
checking for wcsstr... yes
checking for wcscmp... yes
checking for wcsncmp... yes
checking for wcscasecmp... yes
checking for _wcsicmp... no
checking for wcsncasecmp... yes
checking for _wcsnicmp... no
checking for strlen... yes
checking for strlcpy... no
checking for strlcat... no
checking for _strrev... no
checking for _strupr... no
checking for _strlwr... no
checking for strchr... yes
checking for strrchr... yes
checking for strstr... yes
checking for strtok_r... yes
checking for itoa... no
checking for _ltoa... no
checking for _uitoa... no
checking for _ultoa... no
checking for strtol... yes
checking for strtoul... yes
checking for _i64toa... no
checking for _ui64toa... no
checking for strtoll... yes
checking for strtoull... yes
checking for atoi... yes
checking for atof... yes
checking for strcmp... yes
checking for strncmp... yes
checking for _stricmp... no
checking for strcasecmp... yes
checking for _strnicmp... no
checking for strncasecmp... yes
checking for vsscanf... yes
checking for vsnprintf... yes
checking for fopen64... yes
checking for fseeko... yes
checking for fseeko64... yes
checking for sigaction... yes
checking for setjmp... yes
checking for nanosleep... yes
checking for sysconf... yes
checking for sysctlbyname... no
checking for getauxval... yes
checking for elf_aux_info... no
checking for poll... yes
checking for _Exit... yes
checking for pow in -lm... yes
checking for acos... yes
checking for acosf... yes
checking for asin... yes
checking for asinf... yes
checking for atan... yes
checking for atanf... yes
checking for atan2... yes
checking for atan2f... yes
checking for ceil... yes
checking for ceilf... yes
checking for copysign... yes
checking for copysignf... yes
checking for cos... yes
checking for cosf... yes
checking for exp... yes
checking for expf... yes
checking for fabs... yes
checking for fabsf... yes
checking for floor... yes
checking for floorf... yes
checking for trunc... yes
checking for truncf... yes
checking for fmod... yes
checking for fmodf... yes
checking for log... yes
checking for logf... yes
checking for log10... yes
checking for log10f... yes
checking for pow... yes
checking for powf... yes
checking for scalbn... yes
checking for scalbnf... yes
checking for sin... yes
checking for sinf... yes
checking for sqrt... yes
checking for sqrtf... yes
checking for tan... yes
checking for tanf... yes
checking for iconv_open in -liconv... no
checking for iconv... yes
checking for struct sigaction.sa_sigaction... yes
checking libunwind.h usability... no
checking libunwind.h presence... no
checking for libunwind.h... no
checking for GCC builtin atomic operations... yes
checking for GCC -mmmx option... yes
checking for GCC -m3dnow option... yes
checking for GCC -msse option... yes
checking for GCC -msse2 option... yes
checking for GCC -msse3 option... yes
checking immintrin.h usability... yes
checking immintrin.h presence... yes
checking for immintrin.h... yes
checking for Altivec with GCC altivec.h and -maltivec option... no
checking for Altivec with GCC -maltivec option... no
checking for Altivec with GCC altivec.h and -faltivec option... no
checking for Altivec with GCC -faltivec option... no
checking for GCC -Wall option... yes
checking for necessary GCC -Wno-multichar option... no
checking for GCC -fno-strict-aliasing option... yes
checking for GCC -fvisibility=hidden option... yes
checking for GCC -Wdeclaration-after-statement option... yes
checking for dlopen... yes
checking for dlopen in -lc... no
checking for dlopen in -ldl... yes
checking for OSS audio support... yes
checking for ALSA CFLAGS...
checking for ALSA LDFLAGS... -lasound -lm -ldl -lpthread
checking for libasound headers version >= 1.0.11... not present.
checking for snd_ctl_open in -lasound... no
checking for PULSEAUDIO... no
checking for JACK... no
checking for artsc-config... no
checking for esd-config... no
checking for ESD - version >= 0.2.8... no
*** The esd-config script installed by ESD could not be found
*** If ESD was installed in PREFIX, make sure PREFIX/bin is in
*** your path, or set the ESD_CONFIG environment variable to the
*** full path to esd-config.
checking audio/audiolib.h usability... no
checking audio/audiolib.h presence... no
checking for audio/audiolib.h... no
checking for AuOpenServer in -laudio... no
checking for NAS audio support... no
checking sndio.h usability... no
checking sndio.h presence... no
checking for sndio.h... no
checking for sio_open in -lsndio... no
checking for sndio audio support... no
checking samplerate.h usability... yes
checking samplerate.h presence... yes
checking for samplerate.h... yes
-- dynamic libsamplerate -> libsamplerate.so.0
checking for RPI... no
checking for Raspberry Pi... no
checking for X... libraries , headers
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... no
checking for X11/extensions/Xext.h... no
configure: error:
*** Missing Xext.h, maybe you need to install the libxext-dev package?
Failed to Execute ./configure --prefix=/root/ffmpeg-build-script/workspace --disable-shared --enable-static