rtp2httpd icon indicating copy to clipboard operation
rtp2httpd copied to clipboard

带密码认证的rtsp无法播放

Open lazymartin opened this issue 9 months ago • 10 comments

potplayer播放 http://192.168.1.1:12345/rtsp/user:[email protected]:554/Streaming/Channels/101 日志提示:Client connection error: Connection reset by peer

potplayer播放 rtsp://user:[email protected]:554/Streaming/Channels/101 正常

lazymartin avatar Feb 04 '26 03:02 lazymartin

这个rtsp源是什么类型,iptv还是摄像头监控? 目前只支持转发RTP/MP2T单流的rtsp源,也就是运营商iptv用的格式。不支持音视频分开双流的rtsp(摄像头监控用的)

stackia avatar Feb 04 '26 05:02 stackia

可以提供一下完整流程的DEBJG级别日志

stackia avatar Feb 04 '26 05:02 stackia

16:02:30 INFO [Worker 0] New client 127.0.0.1:43798 requested URL: /4K/%E6%B5%8B%E8%AF%95?r2h-token=xxx(method: GET) 16:02:30 DEBUG [Worker 0] r2h-token validated (source: query) 16:02:30 INFO [Worker 0] Service matched: 4K/测试 16:02:30 DEBUG [Worker 0] Creating RTSP service with merged URL: rtsp://xxx:[email protected]:554/Streaming/Channels/101?r2h-token=xxx 16:02:30 DEBUG [Worker 0] Parsed RTSP URL: rtsp://xxx:[email protected]:554/Streaming/Channels/101?r2h-token=xxx 16:02:30 INFO [Worker 0] X-Forwarded-For accepted: 58.xxx.xxx.xxx 16:02:30 DEBUG [Worker 0] Timezone: No TZ marker in User-Agent 16:02:30 DEBUG [Worker 0] RTSP: Parsed URL - host=172.16.1.253, port=554, path=/Streaming/Channels/101?r2h-token=xxx 16:02:30 DEBUG [Worker 0] RTSP: Connection to 172.16.1.253:554 in progress (async) 16:02:30 DEBUG [Worker 0] RTSP: Socket registered with epoll for connection completion 16:02:30 DEBUG [Worker 0] RTSP: Async connection initiated, state=1 16:02:33 ERROR [Worker 0] RTSP: Socket error: Host is unreachable 16:02:33 DEBUG [Worker 0] RTSP: Auto-cleanup triggered on ERROR state 16:02:33 DEBUG [Worker 0] RTSP: Main socket closed 16:02:33 DEBUG [Worker 0] RTSP: Session cleanup complete 16:02:33 ERROR [Worker 0] RTSP: Socket event handling failed

adxing avatar Feb 04 '26 08:02 adxing

这个rtsp源是什么类型,iptv还是摄像头监控? 目前只支持转发RTP/MP2T单流的rtsp源,也就是运营商iptv用的格式。不支持音视频分开双流的rtsp(摄像头监控用的)

是海康录像机的源,debug日志已发

adxing avatar Feb 04 '26 08:02 adxing

目前不支持监控录机RTSP转HTTP,除非它输出的是和iptv一样的RTP/mpeg-ts单流(监控基本都是输出音视频双流)

而且从日志看,你的网络都没通 (连接 172.16.1.253 提示 RTSP: Socket error: Host is unreachable)

stackia avatar Feb 04 '26 08:02 stackia

就是@前面有帐号和密码验证才能通的,用potplayer就可以播放

adxing avatar Feb 04 '26 08:02 adxing

这个摄像头是只有视频流的,没有音频流的,应该是无法校验用户名和密码

adxing avatar Feb 04 '26 08:02 adxing

目前不支持监控录机RTSP转HTTP,除非它输出的是和iptv一样的RTP/mpeg-ts单流(监控基本都是输出音视频双流)

而且从日志看,你的网络都没通 (连接 172.16.1.253 提示 RTSP: Socket error: Host is unreachable)

Feb 04 11:05:12 YDL rtp2httpd[418604]: [Worker 0] Async HTTP fetch started, pipe_fd=9 Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] Async HTTP(S) fetch started, waiting for completion Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] Async HTTP fetch pipe closed, checking results Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] Async HTTP fetch completed successfully (2304073 bytes, fd=11): https://raw.githubusercontent.com/fanmingming/live/main/e.xml Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] EPG ETag calculated: 436fa7e435c0c71a41027ffd572e6883 Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] EPG data cached: 2304073 bytes, fd=11 (uncompressed), ETag=436fa7e435c0c71a41027ffd572e6883 Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] New client 192.168.1.2:1734 requested URL: /rtsp/user:[email protected]:554/Streaming/Channels/101 (method: GET) Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] Parsed RTSP URL: rtsp://user:[email protected]:554/Streaming/Channels/101 Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] RTSP: Parsed URL - host=10.0.30.3, port=554, path=/Streaming/Channels/101 Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] RTSP: Connection to 10.0.30.3:554 in progress (async) Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] RTSP: Socket registered with epoll for connection completion Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] RTSP: Async connection initiated, state=1 Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] Client disconnected Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] RTSP: Main socket closed Feb 04 11:05:34 YDL rtp2httpd[418604]: [Worker 0] RTSP: Session cleanup complete Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] New client 192.168.1.2:1736 requested URL: /rtsp/user:[email protected]:554/Streaming/Channels/101 (method: GET) Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] Parsed RTSP URL: rtsp://user:[email protected]:554/Streaming/Channels/101 Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] Timezone: No TZ marker in User-Agent Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Parsed URL - host=10.0.30.3, port=554, path=/Streaming/Channels/101 Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Connection to 10.0.30.3:554 in progress (async) Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Socket registered with epoll for connection completion Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Async connection initiated, state=1 Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] Client disconnected Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Main socket closed Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Session cleanup complete Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] New client 192.168.1.2:1737 requested URL: /rtsp/user:[email protected]:554/Streaming/Channels/101 (method: GET) Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] Parsed RTSP URL: rtsp://user:[email protected]:554/Streaming/Channels/101 Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] Timezone: No TZ marker in User-Agent Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Parsed URL - host=10.0.30.3, port=554, path=/Streaming/Channels/101 Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Connection to 10.0.30.3:554 in progress (async) Feb 04 11:05:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Socket registered with epoll for connection completion Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] RTSP: Async connection initiated, state=1 Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] Client connection error: Connection reset by peer Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] RTSP: Main socket closed Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] RTSP: Session cleanup complete Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] New client 192.168.1.2:1738 requested URL: /rtsp/user:[email protected]:554/Streaming/Channels/101 (method: GET) Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] Parsed RTSP URL: rtsp://user:[email protected]:554/Streaming/Channels/101 Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] Timezone: No TZ marker in User-Agent Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] RTSP: Parsed URL - host=10.0.30.3, port=554, path=/Streaming/Channels/101 Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] RTSP: Connection to 10.0.30.3:554 in progress (async) Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] RTSP: Socket registered with epoll for connection completion Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] RTSP: Async connection initiated, state=1 Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] Client connection error: Connection reset by peer Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] RTSP: Main socket closed Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] RTSP: Session cleanup complete Feb 04 11:05:51 YDL rtp2httpd[418604]: [Worker 0] New client 192.168.1.2:1739 requested URL: /rtsp/user:[email protected]:554/Streaming/Channels/101 (method: GET) Feb 04 11:06:38 YDL rtp2httpd[418604]: [Worker 0] Parsed RTSP URL: rtsp://user:[email protected]:554/Streaming/Channels/101 Feb 04 11:06:38 YDL rtp2httpd[418604]: [Worker 0] Timezone: No TZ marker in User-Agent Feb 04 11:06:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Parsed URL - host=10.0.30.3, port=554, path=/Streaming/Channels/101 Feb 04 11:06:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Connection to 10.0.30.3:554 in progress (async) Feb 04 11:06:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Socket registered with epoll for connection completion Feb 04 11:06:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Async connection initiated, state=1 Feb 04 11:06:38 YDL rtp2httpd[418604]: [Worker 0] Client connection error: Connection reset by peer Feb 04 11:06:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Main socket closed Feb 04 11:06:38 YDL rtp2httpd[418604]: [Worker 0] RTSP: Session cleanup complete

确实是海康的摄像头,期望以后能支持,这样在电视也能看监控。感谢大佬!!

lazymartin avatar Feb 04 '26 10:02 lazymartin

这个摄像头是只有视频流的,没有音频流的,应该是无法校验用户名和密码

目前代码是实现了 RTSP 用户名和密码校验的。

尽管摄像头即使只有一条流,目前也大概率无法支持。因为现在只实现了对 mpeg-ts 封装的视频流的支持。摄像头一般不使用这种封装(一般是 RTP 承载裸 H.264/H.265/MJPEG 流,没有额外封装),即使成功通过 rtp2httpd 转换成 HTTP,在大多数播放器应该也没法解码。

stackia avatar Feb 04 '26 11:02 stackia

同样也是海康摄像头的rstp发现访问不了,查了一下issues原来不支持,期望以后能支持

11:37:37 INFO [Worker 0] New client 10.0.0.189:2587 requested URL: /rtsp/admin:@192.168.1.16:554/Streaming/Channels/101 (method: GET) 11:37:37 DEBUG [Worker 0] Parsed RTSP URL: rtsp://admin:@@192.168.1.16:554/Streaming/Channels/101 11:37:37 DEBUG [Worker 0] RTSP: Parsed URL - host=192.168.1.16, port=554, path=/Streaming/Channels/101 11:37:37 DEBUG [Worker 0] RTSP: Connection to 192.168.1.16:554 in progress (async) 11:37:37 INFO [Worker 0] RTSP: Connected to 192.168.1.16:554 11:37:37 DEBUG [Worker 0] RTSP: Prepared request: OPTIONS (CSeq:1) + Basic Auth 11:37:37 DEBUG [Worker 0] RTSP: Received 200 OK, methods: OPTIONS,DESCRIBE,PLAY,PAUSE,SETUP,TEARDOWN,SET_PARAMETER,GET_PARAMETER 11:37:37 DEBUG [Worker 0] RTSP: Prepared request: DESCRIBE (CSeq:2) + Basic Auth 11:37:37 DEBUG [Worker 0] RTSP: Received 401 Unauthorized, Digest realm="IP Camera(16861)", nonce="533cf33087802f" 11:37:37 DEBUG [Worker 0] RTSP: Retrying DESCRIBE (CSeq:3) with Digest auth, response="9571fd1ffdc78" 11:37:37 DEBUG [Worker 0] RTSP: Received 200 OK, Content-Type: application/sdp, Content-Length: 564 11:37:37 DEBUG [Worker 0] RTSP: SDP: H265, 1920x1080 11:37:37 DEBUG [Worker 0] RTSP: Setting up UDP sockets bound to ports 10490 (RTP) and 10491 (RTCP) 11;37:37 DEBUG [Worker 0] RTSP: Prepared request: SETUP (CSeq:4) + Digest auth, Transport: MP2T/RTP/TCP;...;client_port=10490-10491 11:37:37 DEBUG [Worker 0] RTSP: Server transport response: MP2T/RTP/TCP;interleaved=0-1;server_port=8276-8277 11:37:37 INFO [Worker 0] RTSP: Server selected MP2T/RTP transport 11:37:37 INFO [Worker 0] RTSP: Using TCP interleaved transport (keepalive 30000ms) 11:37:37 DEBUG [Worker 0] RTSP: Closed UDP sockets (switched to TCP mode) 11:37:37 DEBUG [Worker 0] RTSP: Received 200 OK, Session: 1427835891; timeout=60 11:37:37 DEBUG [Worker 0] RTSP: Prepared request: PLAY (CSeq:5) + Digest auth, Session: 1427835891 11:37:38 DEBUG [Worker 0] RTSP: Received 200 OK, RTP-Info: seq=0; rtptime=0 11:37:38 INFO [Worker 0] RTSP: Stream started successfully 11:37:38 ERROR [Worker 0] RTSP: Socket error: Connection reset by peer 11:37:38 INFO [Worker 0] RTSP: Upstream closed during PLAYING, draining client 11:37:38 DEBUG [Worker 0] RTSP: Session cleanup complete

Saxon-Sun avatar Apr 29 '26 03:04 Saxon-Sun