ZLMediaKit / ZLMediaKit

WebRTC/RTSP/RTMP/HTTP/HLS/HTTP-FLV/WebSocket-FLV/HTTP-TS/HTTP-fMP4/WebSocket-TS/WebSocket-fMP4/GB28181/SRT server and client framework based on C++11
https://docs.zlmediakit.com
Other
13.66k stars 3.37k forks source link

[BUG] webrtc 播放报错:接受rtp/rtcp/datachannel超时 #2610

Closed RlonLL11FE closed 1 year ago

RlonLL11FE commented 1 year ago

现象描述

使用OBS开启推流后,在demo里点【start】,调用/index/api/webrtc?app=live&stream=livestream&type=play,返回code:0,但是前端一直不开始播放,过了一会儿mediaserver报错“接受rtp/rtcp/datachannel超时”

如何复现?

昨天从git上pull的最新的代码,问题是必现的,我试用之前的版本没有这个问题

相关日志或截图

展开查看详细日志
2023-07-03 17:46:52.327 I [MediaServer.exe] [16736-18004] main.cpp:261 start_main | ZLMediaKit(git hash:6b9889a/2023-07-02T12:45:07+08:00,branch:master,build time:2023-07-03T14:11:55)
2023-07-03 17:46:52.345 D [MediaServer.exe] [16736-18004] SSLBox.cpp:174 setContext | Add certificate of: default.zlmediakit.com
2023-07-03 17:46:52.346 D [MediaServer.exe] [16736-stamp thread] util.cpp:366 operator () | Stamp thread started
2023-07-03 17:46:52.350 I [MediaServer.exe] [16736-18004] EventPoller.cpp:482 EventPollerPool | EventPoller created size: 4
2023-07-03 17:46:52.351 I [MediaServer.exe] [16736-18004] TcpServer.cpp:213 start_l | TCP server listening on [::]: 554
2023-07-03 17:46:52.353 I [MediaServer.exe] [16736-18004] TcpServer.cpp:213 start_l | TCP server listening on [::]: 332
2023-07-03 17:46:52.354 I [MediaServer.exe] [16736-18004] TcpServer.cpp:213 start_l | TCP server listening on [::]: 1935
2023-07-03 17:46:52.355 I [MediaServer.exe] [16736-18004] TcpServer.cpp:213 start_l | TCP server listening on [::]: 19350
2023-07-03 17:46:52.356 I [MediaServer.exe] [16736-18004] TcpServer.cpp:213 start_l | TCP server listening on [::]: 80
2023-07-03 17:46:52.357 I [MediaServer.exe] [16736-18004] TcpServer.cpp:213 start_l | TCP server listening on [::]: 443
2023-07-03 17:46:52.358 I [MediaServer.exe] [16736-18004] TcpServer.cpp:213 start_l | TCP server listening on [::]: 9000
2023-07-03 17:46:52.360 I [MediaServer.exe] [16736-18004] TcpServer.cpp:213 start_l | TCP server listening on [::]: 10000
2023-07-03 17:46:52.361 I [MediaServer.exe] [16736-18004] UdpServer.cpp:108 start_l | UDP server bind to [::]: 10000
2023-07-03 17:46:52.363 I [MediaServer.exe] [16736-18004] UdpServer.cpp:108 start_l | UDP server bind to [::]: 9000
2023-07-03 17:46:52.363 I [MediaServer.exe] [16736-18004] main.cpp:404 start_main | 已启动http api 接口
2023-07-03 17:46:52.363 I [MediaServer.exe] [16736-18004] main.cpp:406 start_main | 已启动http hook 接口
2023-07-03 17:46:52.601 D [MediaServer.exe] [16736-event poller 0] RtmpSession.cpp:130 operator () | 1-532(127.0.0.1:55199) publish 回复时间:0ms
2023-07-03 17:46:53.020 I [MediaServer.exe] [16736-event poller 0] MediaSource.cpp:506 emitEvent | 媒体注册:rtmp://__defaultVhost__/live/livestream
2023-07-03 17:46:53.119 D [MediaServer.exe] [16736-event poller 0] MediaSink.cpp:150 emitAllTrackReady | All track ready use 93ms
2023-07-03 17:46:53.120 I [MediaServer.exe] [16736-event poller 0] MediaSource.cpp:506 emitEvent | 媒体注册:fmp4://__defaultVhost__/live/livestream
2023-07-03 17:46:53.121 I [MediaServer.exe] [16736-event poller 0] MultiMediaSourceMuxer.cpp:428 onAllTrackReady | stream: rtmp://__defaultVhost__/live/livestream , codec info: H264[1280/720/30] mpeg4-generic[48000/2/16] 
2023-07-03 17:46:53.121 I [MediaServer.exe] [16736-event poller 0] MediaSource.cpp:506 emitEvent | 媒体注册:rtsp://__defaultVhost__/live/livestream
2023-07-03 17:46:53.121 I [MediaServer.exe] [16736-event poller 0] MediaSource.cpp:506 emitEvent | 媒体注册:ts://__defaultVhost__/live/livestream
2023-07-03 17:47:01.421 I [MediaServer.exe] [16736-event poller 0] MediaSource.cpp:506 emitEvent | 媒体注册:hls://__defaultVhost__/live/livestream
2023-07-03 17:47:09.370 I [MediaServer.exe] [16736-event poller 1] WebRtcTransport.cpp:422 WebRtcTransportImp | zlm_1
2023-07-03 17:47:09.370 D [MediaServer.exe] [16736-event poller 1] DtlsTransport.cpp:456 CreateSslCtx | setting SRTP cryptoSuites for DTLS: SRTP_AEAD_AES_256_GCM:SRTP_AEAD_AES_128_GCM:SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32
2023-07-03 17:47:09.371 D [MediaServer.exe] [16736-event poller 1] DtlsTransport.cpp:538 GenerateFingerprints | sha-1   fingerprint: 2E:7D:49:19:98:56:9D:64:9E:9D:E6:D7:9F:DB:A8:01:39:68:6A:8B
2023-07-03 17:47:09.371 D [MediaServer.exe] [16736-event poller 1] DtlsTransport.cpp:538 GenerateFingerprints | sha-224 fingerprint: 71:B9:1B:70:7E:3D:DB:50:9B:1C:CF:0F:FC:01:50:FA:3D:70:A2:2C:0B:0F:94:42:27:33:88:26
2023-07-03 17:47:09.371 D [MediaServer.exe] [16736-event poller 1] DtlsTransport.cpp:538 GenerateFingerprints | sha-256 fingerprint: D5:CF:05:32:F8:6F:B2:72:7B:93:3C:C2:08:10:AE:2D:6F:28:07:D7:DF:41:85:25:88:1E:D3:CB:DF:60:5B:34
2023-07-03 17:47:09.371 D [MediaServer.exe] [16736-event poller 1] DtlsTransport.cpp:538 GenerateFingerprints | sha-384 fingerprint: 44:F5:3F:15:81:75:AE:AC:28:92:DC:FB:B4:80:14:D1:03:6B:7F:9B:4A:B1:4C:D1:A3:D9:B3:03:DF:98:A8:41:7A:91:C7:E4:43:CD:38:4B:56:B0:99:BA:2E:69:8A:BA
2023-07-03 17:47:09.371 D [MediaServer.exe] [16736-event poller 1] DtlsTransport.cpp:538 GenerateFingerprints | sha-512 fingerprint: E5:EB:E2:49:A4:0A:B1:12:90:52:5E:DB:82:65:D4:E0:51:A0:E7:10:8A:C3:A2:DA:3F:28:06:89:DF:3F:AD:28:2F:42:3C:71:89:C6:92:13:34:73:4C:1C:4D:DE:AC:1D:77:3C:78:09:6F:7B:7F:B1:BE:18:1A:0A:57:6A:FA:A0
2023-07-03 17:47:09.396 D [MediaServer.exe] [16736-event poller 1] WebApi.cpp:250 http api debug | 

# request:

POST /index/api/webrtc?app=live&stream=livestream&type=play

# header:

Accept : application/json, text/plain, */*

Accept-Encoding : gzip, deflate

Accept-Language : zh-CN,zh;q=0.9

Connection : keep-alive

Content-Length : 6474

Content-Type : text/plain;charset=UTF-8

Host : 192.168.110.66

Origin : http://192.168.110.66

Referer : http://192.168.110.66/webrtc/

User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36

# content:

v=0

o=- 2977847470059747441 2 IN IP4 127.0.0.1

s=-

t=0 0

a=group:BUNDLE 0 1

a=extmap-allow-mixed

a=msid-semantic: WMS

m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 35 36 37 38 102 103 104 105 106 107 108 109 127 125 39 40 41 42 43 44 45 46 47 48 112 113 114 115 116 117 118 49

c=IN IP4 0.0.0.0

a=rtcp:9 IN IP4 0.0.0.0

a=ice-ufrag:WLUC

a=ice-pwd:AnH44N2ckPcPhTVOxLiqKsWA

a=ice-options:trickle

a=fingerprint:sha-256 9B:E9:79:53:9F:AC:2C:1D:56:0A:5B:A3:1F:30:83:63:1D:7A:CD:12:3E:40:86:03:6C:91:20:9D:99:0E:6F:35

a=setup:actpass

a=mid:0

a=extmap:1 urn:ietf:params:rtp-hdrext:toffset

a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time

a=extmap:3 urn:3gpp:video-orientation

a=extmap:4 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01

a=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay

a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type

a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing

a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space

a=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid

a=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id

a=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id

a=recvonly

a=rtcp-mux

a=rtcp-rsize

a=rtpmap:96 VP8/90000

a=rtcp-fb:96 goog-remb

a=rtcp-fb:96 transport-cc

a=rtcp-fb:96 ccm fir

a=rtcp-fb:96 nack

a=rtcp-fb:96 nack pli

a=rtpmap:97 rtx/90000

a=fmtp:97 apt=96

a=rtpmap:98 VP9/90000

a=rtcp-fb:98 goog-remb

a=rtcp-fb:98 transport-cc

a=rtcp-fb:98 ccm fir

a=rtcp-fb:98 nack

a=rtcp-fb:98 nack pli

a=fmtp:98 profile-id=0

a=rtpmap:99 rtx/90000

a=fmtp:99 apt=98

a=rtpmap:100 VP9/90000

a=rtcp-fb:100 goog-remb

a=rtcp-fb:100 transport-cc

a=rtcp-fb:100 ccm fir

a=rtcp-fb:100 nack

a=rtcp-fb:100 nack pli

a=fmtp:100 profile-id=2

a=rtpmap:101 rtx/90000

a=fmtp:101 apt=100

a=rtpmap:35 VP9/90000

a=rtcp-fb:35 goog-remb

a=rtcp-fb:35 transport-cc

a=rtcp-fb:35 ccm fir

a=rtcp-fb:35 nack

a=rtcp-fb:35 nack pli

a=fmtp:35 profile-id=1

a=rtpmap:36 rtx/90000

a=fmtp:36 apt=35

a=rtpmap:37 VP9/90000

a=rtcp-fb:37 goog-remb

a=rtcp-fb:37 transport-cc

a=rtcp-fb:37 ccm fir

a=rtcp-fb:37 nack

a=rtcp-fb:37 nack pli

a=fmtp:37 profile-id=3

a=rtpmap:38 rtx/90000

a=fmtp:38 apt=37

a=rtpmap:102 H264/90000

a=rtcp-fb:102 goog-remb

a=rtcp-fb:102 transport-cc

a=rtcp-fb:102 ccm fir

a=rtcp-fb:102 nack

a=rtcp-fb:102 nack pli

a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f

a=rtpmap:103 rtx/90000

a=fmtp:103 apt=102

a=rtpmap:104 H264/90000

a=rtcp-fb:104 goog-remb

a=rtcp-fb:104 transport-cc

a=rtcp-fb:104 ccm fir

a=rtcp-fb:104 nack

a=rtcp-fb:104 nack pli

a=fmtp:104 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f

a=rtpmap:105 rtx/90000

a=fmtp:105 apt=104

a=rtpmap:106 H264/90000

a=rtcp-fb:106 goog-remb

a=rtcp-fb:106 transport-cc

a=rtcp-fb:106 ccm fir

a=rtcp-fb:106 nack

a=rtcp-fb:106 nack pli

a=fmtp:106 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f

a=rtpmap:107 rtx/90000

a=fmtp:107 apt=106

a=rtpmap:108 H264/90000

a=rtcp-fb:108 goog-remb

a=rtcp-fb:108 transport-cc

a=rtcp-fb:108 ccm fir

a=rtcp-fb:108 nack

a=rtcp-fb:108 nack pli

a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f

a=rtpmap:109 rtx/90000

a=fmtp:109 apt=108

a=rtpmap:127 H264/90000

a=rtcp-fb:127 goog-remb

a=rtcp-fb:127 transport-cc

a=rtcp-fb:127 ccm fir

a=rtcp-fb:127 nack

a=rtcp-fb:127 nack pli

a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f

a=rtpmap:125 rtx/90000

a=fmtp:125 apt=127

a=rtpmap:39 H264/90000

a=rtcp-fb:39 goog-remb

a=rtcp-fb:39 transport-cc

a=rtcp-fb:39 ccm fir

a=rtcp-fb:39 nack

a=rtcp-fb:39 nack pli

a=fmtp:39 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f

a=rtpmap:40 rtx/90000

a=fmtp:40 apt=39

a=rtpmap:41 H264/90000

a=rtcp-fb:41 goog-remb

a=rtcp-fb:41 transport-cc

a=rtcp-fb:41 ccm fir

a=rtcp-fb:41 nack

a=rtcp-fb:41 nack pli

a=fmtp:41 level-asymmetry-allowed=1;pack

# response:

{
    "code" : 0,
    "id" : "zlm_1",
    "sdp" : "v=0\r\no=- 2977847470059747441 2 IN IP4 192.168.5.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\na=msid-semantic: WMS\r\na=ice-lite\r\nm=video 0 UDP/TLS/RTP/SAVPF 112 113\r\nc=IN IP4 192.168.5.1\r\na=ice-ufrag:zlm_1\r\na=ice-pwd:UxfooEUK1ijN0WNFWXuNHsiW\r\na=ice-options:trickle\r\na=fingerprint:sha-256 D5:CF:05:32:F8:6F:B2:72:7B:93:3C:C2:08:10:AE:2D:6F:28:07:D7:DF:41:85:25:88:1E:D3:CB:DF:60:5B:34\r\na=setup:passive\r\na=mid:0\r\na=ice-lite\r\na=extmap:1 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=sendonly\r\na=rtcp-mux\r\na=rtpmap:112 H264/90000\r\na=rtcp-fb:112 ccm fir\r\na=rtcp-fb:112 goog-remb\r\na=rtcp-fb:112 nack\r\na=rtcp-fb:112 nack pli\r\na=rtcp-fb:112 transport-cc\r\na=fmtp:112 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f\r\na=rtpmap:113 rtx/90000\r\na=fmtp:113 apt=112\r\na=msid:zlmediakit-mslabel zlmediakit-label\r\na=ssrc:1 cname:zlmediakit-rtp\r\na=ssrc:1 msid:zlmediakit-mslabel zlmediakit-label\r\na=ssrc:1 mslabel:zlmediakit-mslabel\r\na=ssrc:1 label:zlmediakit-label\r\na=ssrc:3 cname:zlmediakit-rtp\r\na=ssrc:3 msid:zlmediakit-mslabel zlmediakit-label\r\na=ssrc:3 mslabel:zlmediakit-mslabel\r\na=ssrc:3 label:zlmediakit-label\r\na=ssrc-group:FID 1 3\r\nm=audio 0 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 192.168.5.1\r\na=ice-ufrag:zlm_1\r\na=ice-pwd:UxfooEUK1ijN0WNFWXuNHsiW\r\na=ice-options:trickle\r\na=fingerprint:sha-256 D5:CF:05:32:F8:6F:B2:72:7B:93:3C:C2:08:10:AE:2D:6F:28:07:D7:DF:41:85:25:88:1E:D3:CB:DF:60:5B:34\r\na=setup:passive\r\na=mid:1\r\na=ice-lite\r\na=extmap:14 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=inactive\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=msid:zlmediakit-mslabel zlmediakit-label\r\na=ssrc:2 cname:zlmediakit-rtp\r\na=ssrc:2 msid:zlmediakit-mslabel zlmediakit-label\r\na=ssrc:2 mslabel:zlmediakit-mslabel\r\na=ssrc:2 label:zlmediakit-label\r\n",
    "type" : "answer"
}
2023-07-03 17:47:24.389 W [MediaServer.exe] [16736-event poller 1] WebRtcTransport.cpp:1075 onShutdown | 2(接受rtp/rtcp/datachannel超时)
2023-07-03 17:47:24.389 I [MediaServer.exe] [16736-event poller 1] WebRtcTransport.cpp:426 ~WebRtcTransportImp | zlm_1
2023-07-03 17:47:58.588 W [MediaServer.exe] [16736-event poller 0] EventPoller.cpp:201 async_l | take time: 15ms, thread may be overloaded
2023-07-03 17:48:02.610 W [MediaServer.exe] [16736-event poller 0] EventPoller.cpp:201 async_l | take time: 16ms, thread may be overloaded

配置

展开查看详细配置
; auto-generated by mINI class {

[api]
apiDebug=1
defaultSnap=./www/logo.png
secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc
snapRoot=./www/snap/

[cluster]
origin_url=
retry_count=3
timeout_sec=15

[ffmpeg]
bin=ffmpeg
cmd=%s -re -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s
log=./ffmpeg/ffmpeg.log
restart_sec=0
snap=%s -i %s -y -f mjpeg -frames:v 1 %s

[general]
check_nvidia_dev=1
enableVhost=0
enable_ffmpeg_log=0
flowThreshold=1024
maxStreamWaitMS=15000
mediaServerId=zJrqN1WtrEb0JENs
mergeWriteMS=0
resetWhenRePlay=1
streamNoneReaderDelayMS=20000
unready_frame_cache=100
wait_add_track_ms=3000
wait_track_ready_ms=10000

[hls]
broadcastRecordTs=0
deleteDelaySec=10
fileBufSize=65536
segDur=2
segKeep=0
segNum=3
segRetain=5

[hook]
admin_params=secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc
alive_interval=30.000000
enable=0
on_flow_report=
on_http_access=
on_play=
on_publish=
on_record_mp4=
on_record_ts=
on_rtp_server_timeout=
on_rtsp_auth=
on_rtsp_realm=
on_send_rtp_stopped=
on_server_exited=
on_server_keepalive=
on_server_started=
on_shell_login=
on_stream_changed=
on_stream_none_reader=
on_stream_not_found=
retry=1
retry_delay=3.000000
timeoutSec=10

[http]
allow_cross_domains=1
charSet=gb2312
dirMenu=1
forbidCacheSuffix=
forwarded_ip_header=
keepAliveSecond=15
maxReqSize=40960
notFound=404 Not Found

您访问的资源不存在!


ZLMediaKit(git hash:6b9889a/2023-07-02T12:45:07+08:00,branch:master,build time:2023-07-03T14:11:55)
port=80 rootPath=./www sendBufSize=65536 sslport=443 virtualPath= [multicast] addrMax=239.255.255.255 addrMin=239.0.0.0 udpTTL=64 [protocol] add_mute_audio=1 continue_push_ms=15000 enable_audio=1 enable_fmp4=1 enable_hls=1 enable_hls_fmp4=0 enable_mp4=0 enable_rtmp=1 enable_rtsp=1 enable_ts=1 fmp4_demand=0 hls_demand=0 hls_save_path=./www modify_stamp=2 mp4_as_player=0 mp4_max_second=3600 mp4_save_path=./www rtmp_demand=0 rtsp_demand=0 ts_demand=0 [record] appName=record fastStart=0 fileBufSize=65536 fileRepeat=0 sampleMS=500 [rtc] externIP= port=0 preferredCodecA=PCMU,PCMA,opus,mpeg4-generic preferredCodecV=H264,H265,AV1,VP9,VP8 rembBitRate=0 tcpPort=0 timeoutSec=15 [rtmp] handshakeSecond=15 keepAliveSecond=15 modifyStamp=0 port=1935 sslport=19350 [rtp] audioMtuSize=600 h264_stap_a=1 lowLatency=0 rtpMaxSize=10 videoMtuSize=1400 [rtp_proxy] dumpDir= gop_cache=1 h264_pt=98 h265_pt=99 opus_pt=100 port=10000 port_range=30000-35000 ps_pt=96 timeoutSec=15 [rtsp] authBasic=0 directProxy=1 handshakeSecond=15 keepAliveSecond=15 lowLatency=0 port=554 rtpTransportType=-1 sslport=332 [shell] maxReqSize=1024 port=9000 [srt] latencyMul=4 pktBufSize=8192 port=9000 timeoutSec=5 ; } ---

各种环境信息

xiongguangjie commented 1 year ago

你extern_ip 是否配置正确???

RlonLL11FE commented 1 year ago

配置了,我是本机推流本机拉流播放,extern_ip 试着配了127.0.0.1和局域网IP都不行。

Dw9 commented 1 year ago

@RlonLL11FE 你rtc port没设置(默认8000) 导致sdp里面都没Candidate

RlonLL11FE commented 1 year ago

port=8000 tcpPort=8000 加上这两个配置可以了 image