bluenviron / gortsplib

RTSP 1.0 client and server library for the Go programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make checking SPS/PPS of RTSP SDPs optional

KanyonKris opened this issue · comments

MediaMTX version 1.0.3 added a check for valid SPS/PPS of RTSP SDPs (#394). This broke a webcam RTSP stream that had been working in version 1.0.1 and earlier. Yes it's a cheap webcam and my guess is it's outputting a RTSP stream that is not standard compliant, but should MediaMTX refuse to use the stream just because the SPS/PPS is invalid? Perhaps add a config option to disable SPS/PPS checking.

Log:
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: 2023/09/05 14:53:54 DEB [path eveast] [RTSP source] c->s OPTIONS rtsp://10.65.0.127:8554/profile1 RTSP/1.0
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: CSeq: 1
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: User-Agent: gortsplib
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]:
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: 2023/09/05 14:53:54 DEB [path eveast] [RTSP source] s->c RTSP/1.0 200 OK
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: CSeq: 1
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Date: Tue Sep 5 20:53:54 2023
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Public: DESCRIBE, SETUP, PLAY, PAUSE, OPTIONS, TEARDOWN,GET_PARAMETER,SET_PARAMETER
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Server: YGTek RTSP Server 2.0
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]:
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: 2023/09/05 14:53:54 DEB [path eveast] [RTSP source] c->s DESCRIBE rtsp://10.65.0.127:8554/profile1 RTSP/1.0
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Accept: application/sdp
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: CSeq: 2
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: User-Agent: gortsplib
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]:
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: 2023/09/05 14:53:54 DEB [path eveast] [RTSP source] s->c RTSP/1.0 401 Unauthorized
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: CSeq: 2
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Date: Tue Sep 5 20:53:54 2023
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Server: YGTek RTSP Server 2.0
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: WWW-Authenticate: Basic realm="ygtechnologyshanghai"
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]:
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: 2023/09/05 14:53:54 DEB [path eveast] [RTSP source] c->s DESCRIBE rtsp://10.65.0.127:8554/profile1 RTSP/1.0
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Accept: application/sdp
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Authorization: Basic ZXY6ZXYx
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: CSeq: 3
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: User-Agent: gortsplib
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]:
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: 2023/09/05 14:53:54 DEB [path eveast] [RTSP source] s->c RTSP/1.0 200 OK
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: CSeq: 3
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Content-Base: rtsp://10.65.0.127:8554/profile1/
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Content-Length: 530
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Content-Type: application/sdp
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Date: Tue Sep 5 20:53:54 2023
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Server: YGTek RTSP Server 2.0
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: Session: 2111224323
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]:
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: v=0
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: o=- 0 0 IN IP4 10.65.0.127
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: s=session
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: c=IN IP4 10.65.0.127
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: t=0 0
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: a=control:*
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: a=range:npt=0-
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: m=video 0 RTP/AVP 96
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: a=rtpmap:96 H265/90000
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: a=fmtp:96 profile-space=0;profile-id=0;tier-flag=0;level-id=0;interop-constraints=000000000000;sprop-vps=AAAAAUABDAH//wFgAAADAAADAAADAAADAJasCQ==;sprop-sps=AAAAAUIBAQFgAAADAAADAAADAAADAJag>
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: a=control:rtsp://10.65.0.127:8554/profile1/track=v
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: m=audio 0 RTP/AVP 0
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: a=rtpmap:0 PCMU/8000/1
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: a=control:rtsp://10.65.0.127:8554/profile1/track=a
Sep 05 14:53:54 leh-ev-charging mediamtx[39497]: 2023/09/05 14:53:54 ERR [path eveast] [RTSP source] media 1 is invalid: invalid PPS: not a PPS

Hello, i'm going to remove the check, but unfortunately i need another server log from you, since the one you included has the line starting with a=fmtp that is truncated, and it is exactly the line that i need to insert into automatic tests in order to ensure compatibility with your camera forever.

If you have problems with the text editor, attach the server log as a separate file.

Thanks for the quick reply. Sorry about the truncated line, the terminal did that. Here's the full line:

a=fmtp:96 profile-space=0;profile-id=0;tier-flag=0;level-id=0;interop-constraints=000000000000;sprop-vps=AAAAAUABDAH//wFgAAADAAADAAADAAADAJasCQ==;sprop-sps=AAAAAUIBAQFgAAADAAADAAADAAADAJagBaIB4WNrkkya5Zk=;sprop-pps=AAAAAUQB4HawJkA=

FYI, the webcam is a Revotech I706. It's a common design that is sold under other brands. I initially set it to output H264 but a change in MediaMTX v1.0.1 didn't like the H264 from this webcam so I switched to H265. Let me know if want me to change back to H264 and send you logs. More info on the webcam - https://www.amazon.com/dp/B096VK398F

I don't know much about RTSP. Is the SPS/PPS info a nice-to-have or is it useful/essential for gortsplib? If it's not essential it seems good if gortsplib could ignore invalid SPS/PPS data. Certainly I trust your expertise to decide what gortsplib should do.

but a change in MediaMTX v1.0.1 didn't like the H264 from this webcam

which change?

Fixed with #404. If you have issues with H264, feel free to open another issue.

Upgraded to MediaMTX 1.1.0 and I still get an SDP error:
Sep 18 11:47:30 leh-ev-charging mediamtx[19663]: 2023/09/18 11:47:30 ERR [path eveast] [RTSP source] invalid SDP: media 1 is invalid: invalid SPS: not a SPS

Here's the debug log:

Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: 2023/09/18 11:41:02 DEB [path eveast] [RTSP source] [c->s] DESCRIBE rtsp://10.65.0.127:8554/profile1 RTSP/1.0
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: Accept: application/sdp
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: Authorization: Basic ZXY6ZXYx
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: CSeq: 3
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: User-Agent: gortsplib
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]:
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: 2023/09/18 11:41:02 DEB [path eveast] [RTSP source] [s->c] RTSP/1.0 200 OK
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: CSeq: 3
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: Content-Base: rtsp://10.65.0.127:8554/profile1/
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: Content-Length: 420
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: Content-Type: application/sdp
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: Date: Mon Sep 18 17:41:01 2023
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: Server: YGTek RTSP Server 2.0
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: Session: 68754561
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]:
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: v=0
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: o=- 0 0 IN IP4 10.65.0.127
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: s=session
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: c=IN IP4 10.65.0.127
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: t=0 0
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: a=control:*
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: a=range:npt=0-
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: m=video 0 RTP/AVP 96
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: a=rtpmap:96 H264/90000
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: a=fmtp:96 profile-level-id=4DE028;packetization-mode=1;sprop-parameter-sets=AAAAAWdNAB6NjUBaHtCAAAOEAACvyAI=,AAAAAWjuOIA=
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: a=control:rtsp://10.65.0.127:8554/profile1/track=v
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: m=audio 0 RTP/AVP 0
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: a=rtpmap:0 PCMU/8000/1
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: a=control:rtsp://10.65.0.127:8554/profile1/track=a
Sep 18 11:41:02 leh-ev-charging mediamtx[19663]: 2023/09/18 11:41:02 ERR [path eveast] [RTSP source] invalid SDP: media 1 is invalid: invalid SPS: not a SPS

@KanyonKris the new SDP you posted contains a H264 track, while this issue was related to a H265 track. Anyway, i'll try to add support for this one too.

@aler9 ah, that makes sense. That's on me, I should have done H264 back when I first opened this issue. I'm OK to wait for the next release, unless there's a nightly with the H264 fix.

MediaMTX v1.1.1 fixed it. All streams working now. Thank you.