FFMPEG将rtp流转换为已在使用的绑定失败地址



我用Janus网关设置了一个服务器,并使用视频室插件,我试图使用音频端口5002和视频端口5004在本地转发rtp流。这是视频室插件配置

room-1234: {
description = "Demo Room"
secret = "adminpwd"
publishers = 6
bitrate = 128000
fir_freq = 1
#fir_freq = 10
audiocodec = "opus"
videocodec = "vp8"
#videocodec = "h264"
record = false
#rec_dir = "/path/to/recordings-folder"
}

在RTP转发后,我想将视频转换为rtmp,以使用OBS Studio远程获取视频,我用rtmp插件设置了一个nginx服务器。使用ffmpeg,我试图进行这种转换,并创建了包含以下内容的sdp文件:

v=0
o=- 0 0 IN IP4 127.0.0.1
s=RTP Video
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 58.29.100
m=audio 5002 RTP/AVP 111
a=rtpmap:111 OPUS/48000/2
m=video 5004 RTP/AVP 100
a=rtpmap:100 VP8/90000
a=fmtp:100

然后我启动了命令

ffmpeg -protocol_whitelist rtp,udp,file -loglevel trace -analyzeduration 300M -probesize 300M -i config.sdp -c:v copy -c:a aac -ar 16k -ac 1 -preset ultrafast -tune zerolatency rtmp://127.0.0.1/live/1234

但我得到了错误绑定失败的地址已经在使用。低于完整输出

built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100
Splitting the commandline.
Reading option '-protocol_whitelist' ... matched as AVOption 'protocol_whitelist' with argument 'rtp,udp,file'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-analyzeduration' ... matched as AVOption 'analyzeduration' with argument '300M'.
Reading option '-probesize' ... matched as AVOption 'probesize' with argument '300M'.
Reading option '-i' ... matched as input url with argument 'config.sdp'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'aac'.
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '16k'.
Reading option '-ac' ... matched as option 'ac' (set number of audio channels) with argument '1'.
Reading option '-preset' ... matched as AVOption 'preset' with argument 'ultrafast'.
Reading option '-tune' ... matched as AVOption 'tune' with argument 'zerolatency'.
Reading option 'rtmp://127.0.0.1/live/1234' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input url config.sdp.
Successfully parsed a group of options.
Opening an input file: config.sdp.
[NULL @ 0x5594280] Opening 'config.sdp' for reading
Probing sdp score:50 size:205
[sdp @ 0x5594280] Format sdp probed with size=2048 and score=50
[sdp @ 0x5594280] sdp: v='0'
[sdp @ 0x5594280] sdp: o='- 0 0 IN IP4 127.0.0.1'
[sdp @ 0x5594280] sdp: s='RTP Video'
[sdp @ 0x5594280] sdp: c='IN IP4 127.0.0.1'
[sdp @ 0x5594280] sdp: t='0 0'
[sdp @ 0x5594280] sdp: a='tool:libavformat 58.29.100'
[sdp @ 0x5594280] sdp: m='audio 5002 RTP/AVP 111'
[sdp @ 0x5594280] sdp: a='rtpmap:111 OPUS/48000/2'
[sdp @ 0x5594280] audio codec set to: opus
[sdp @ 0x5594280] audio samplerate set to: 48000
[sdp @ 0x5594280] audio channels set to: 2
[sdp @ 0x5594280] sdp: m='video 5004 RTP/AVP 100'
[sdp @ 0x5594280] sdp: a='rtpmap:100 VP8/90000'
[sdp @ 0x5594280] video codec set to: vp8
[sdp @ 0x5594280] sdp: a='fmtp:100'
[udp @ 0x5597980] bind failed: Address already in use
[AVIOContext @ 0x559d580] Statistics: 205 bytes read, 0 seeks
config.sdp: Invalid data found when processing input

我做了很多搜索和尝试,但我真的不知道出了什么问题。你能帮我理解一下这个错误吗?

谢谢!

检查哪个其他进程正在阻塞端口5002或5004:

# netstat -pena | grep -E "5002|5004"

如果罪魁祸首是janus,请检查该端口是否存在于任何janus配置文件中:

# grep -E "5002|5004" -R /etc/janus/

端口5002到5005通常存在于rtp示例安装点配置中的janus.plugin.streaming.jcfg中。这意味着流媒体插件正在使用它们。如果您不需要装入点rtp示例,请将其从janus.plugin.streaming.jcfg中删除。如果您需要,请在rtp_foward中使用不同的端口。

最新更新