0

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

    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

我做了很多搜索和尝试,但我真的无法弄清楚出了什么问题。你能帮我理解错误吗?

谢谢!

4

1 回答 1

0

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

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

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

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

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

于 2020-08-27T17:50:38.130 回答