Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
10.71k
stars
1.4k
forks
source link
RTSP/1.0 400 Bad Request when query parameters are supplied in RTSP URL #3294
When attempting to stream video with RTSP (using Gstreamer), response 400 is given on SETUP request.
Describe how to replicate the issue
Launch MediaMTX with the following config: mediamtx.yml
Docker command I'm using is docker run --restart unless-stopped -v ./src/mediamtx/mediamtx.yml:/mediamtx.yml -v ./src/mediamtx:/app/data -p 8554:8554 -p 1935:1935 -p 8888:8888 -p 8889:8889 -p 8890:8890/udp -p 8189:8189/udp bluenviron/mediamtx
Stream a test video using Gstreamer (v1.22.10), observe the connection has no issues
gst-launch-1.0 videotestsrc ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! x264enc speed-preset=veryfast tune=zerolatency bitrate=800 ! rtspclientsink protocols=tcp location=rtsp://127.0.0.1:8554/mystream
Stream a test video using Gstreamer, with sample query parameters
gst-launch-1.0 videotestsrc ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! x264enc speed-preset=veryfast tune=zerolatency bitrate=800 ! rtspclientsink protocols=tcp location=rtsp://127.0.0.1:8554/mystream?key=value
Observe the response: Error (400): Bad Request
Logs
Logs from server:
```
2024/04/25 12:04:25 INF [RTSP] [conn 192.168.65.1:25173] opened
2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [c->s] OPTIONS rtsp://127.0.0.1:8554/mystream?key=value RTSP/1.0
CSeq: 1
Date: Thu, 25 Apr 2024 12:04:25 GMT
User-Agent: GStreamer/1.22.10
2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [s->c] RTSP/1.0 200 OK
CSeq: 1
Public: DESCRIBE, ANNOUNCE, SETUP, PLAY, RECORD, PAUSE, GET_PARAMETER, TEARDOWN
Server: gortsplib
2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [c->s] ANNOUNCE rtsp://127.0.0.1:8554/mystream?key=value RTSP/1.0
CSeq: 2
Content-Length: 472
Content-Type: application/sdp
Date: Thu, 25 Apr 2024 12:04:25 GMT
User-Agent: GStreamer/1.22.10
v=0
o=- 3559535198 1 IN IP4 127.0.0.1
s=Session streamed with GStreamer
i=rtspclientsink
t=0 0
a=tool:GStreamer
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:819
a=rtpmap:96 H264/90000
a=framerate:30
a=fmtp:96 packetization-mode=1;sprop-parameter-sets=Z/QAHpDZaAoD2wFqDAwMgAAAAwCAAAAeR4sXUA==,aO8xkhk=;profile-level-id=f4001e;level-asymmetry-allowed=1
a=control:stream=0
a=ts-refclk:local
a=mediaclk:sender
a=ssrc:1080323934 cname:user668979404@host-d08b337a
2024/04/25 12:04:25 INF [RTSP] [session 7df37126] created by 192.168.65.1:25173
2024/04/25 12:04:25 DEB [path mystream] created
2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [s->c] RTSP/1.0 200 OK
CSeq: 2
Server: gortsplib
2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [c->s] SETUP rtsp://127.0.0.1:8554/mystream/stream=0?key=value RTSP/1.0
CSeq: 3
Date: Thu, 25 Apr 2024 12:04:25 GMT
Transport: RTP/AVP/TCP;unicast;interleaved=0-1;mode=RECORD
User-Agent: GStreamer/1.22.10
2024/04/25 12:04:26 DEB [RTSP] [conn 192.168.65.1:25173] [s->c] RTSP/1.0 400 Bad Request
CSeq: 3
Server: gortsplib
2024/04/25 12:04:26 INF [RTSP] [conn 192.168.65.1:25173] closed: media not found
2024/04/25 12:04:26 DEB [path mystream] destroyed: not in use
2024/04/25 12:04:26 INF [RTSP] [session 7df37126] destroyed: not in use
```
It seems fine until Gstreamer tries to send data to the /mystream/stream=0 endpoint.
Additional info
The reason I need to send a query parameter is for JWT authentication; as specified in the docs I am trying to send jwt=..., however the process fails as described above.
This issue is being automatically closed because it does not follow the issue template.
Please reopen the issue and make sure to include all sections of the template.
Which version are you using?
v1.8.0
Which operating system are you using?
Describe the issue
When attempting to stream video with RTSP (using Gstreamer), response 400 is given on SETUP request.
Describe how to replicate the issue
gst-launch-1.0 videotestsrc ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! x264enc speed-preset=veryfast tune=zerolatency bitrate=800 ! rtspclientsink protocols=tcp location=rtsp://127.0.0.1:8554/mystream
gst-launch-1.0 videotestsrc ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! x264enc speed-preset=veryfast tune=zerolatency bitrate=800 ! rtspclientsink protocols=tcp location=rtsp://127.0.0.1:8554/mystream?key=value
Error (400): Bad Request
Logs
Logs from server:
``` 2024/04/25 12:04:25 INF [RTSP] [conn 192.168.65.1:25173] opened 2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [c->s] OPTIONS rtsp://127.0.0.1:8554/mystream?key=value RTSP/1.0 CSeq: 1 Date: Thu, 25 Apr 2024 12:04:25 GMT User-Agent: GStreamer/1.22.10 2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [s->c] RTSP/1.0 200 OK CSeq: 1 Public: DESCRIBE, ANNOUNCE, SETUP, PLAY, RECORD, PAUSE, GET_PARAMETER, TEARDOWN Server: gortsplib 2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [c->s] ANNOUNCE rtsp://127.0.0.1:8554/mystream?key=value RTSP/1.0 CSeq: 2 Content-Length: 472 Content-Type: application/sdp Date: Thu, 25 Apr 2024 12:04:25 GMT User-Agent: GStreamer/1.22.10 v=0 o=- 3559535198 1 IN IP4 127.0.0.1 s=Session streamed with GStreamer i=rtspclientsink t=0 0 a=tool:GStreamer m=video 0 RTP/AVP 96 c=IN IP4 0.0.0.0 b=AS:819 a=rtpmap:96 H264/90000 a=framerate:30 a=fmtp:96 packetization-mode=1;sprop-parameter-sets=Z/QAHpDZaAoD2wFqDAwMgAAAAwCAAAAeR4sXUA==,aO8xkhk=;profile-level-id=f4001e;level-asymmetry-allowed=1 a=control:stream=0 a=ts-refclk:local a=mediaclk:sender a=ssrc:1080323934 cname:user668979404@host-d08b337a 2024/04/25 12:04:25 INF [RTSP] [session 7df37126] created by 192.168.65.1:25173 2024/04/25 12:04:25 DEB [path mystream] created 2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [s->c] RTSP/1.0 200 OK CSeq: 2 Server: gortsplib 2024/04/25 12:04:25 DEB [RTSP] [conn 192.168.65.1:25173] [c->s] SETUP rtsp://127.0.0.1:8554/mystream/stream=0?key=value RTSP/1.0 CSeq: 3 Date: Thu, 25 Apr 2024 12:04:25 GMT Transport: RTP/AVP/TCP;unicast;interleaved=0-1;mode=RECORD User-Agent: GStreamer/1.22.10 2024/04/25 12:04:26 DEB [RTSP] [conn 192.168.65.1:25173] [s->c] RTSP/1.0 400 Bad Request CSeq: 3 Server: gortsplib 2024/04/25 12:04:26 INF [RTSP] [conn 192.168.65.1:25173] closed: media not found 2024/04/25 12:04:26 DEB [path mystream] destroyed: not in use 2024/04/25 12:04:26 INF [RTSP] [session 7df37126] destroyed: not in use ```It seems fine until Gstreamer tries to send data to the
/mystream/stream=0
endpoint.Additional info
The reason I need to send a query parameter is for JWT authentication; as specified in the docs I am trying to send
jwt=...
, however the process fails as described above.Did you attach a network dump?
no