mediamtx icon indicating copy to clipboard operation
mediamtx copied to clipboard

RTSP PROXY ISSUE

Open Tabarane opened this issue 2 years ago • 2 comments

Which version are you using?

v0.20.0

Which operating system are you using?

  • [X] Linux amd64 standard
  • [ ] Linux amd64 Docker
  • [ ] Linux arm64 standard
  • [ ] Linux arm64 Docker
  • [ ] Linux arm7 standard
  • [ ] Linux arm7 Docker
  • [ ] Linux arm6 standard
  • [ ] Linux arm6 Docker
  • [X] Windows amd64 standard
  • [ ] Windows amd64 Docker (WSL backend)
  • [ ] macOS amd64 standard
  • [ ] macOS amd64 Docker
  • [ ] Other (please describe)

Describe the issue

I have camera which is sending some type of additional data and its cause the issue, idea is if im using FFMPEG to play it , it will give the below error

[rtsp @ 000001c44d179e80] Nonmatching transport in server reply rtsp://admin:[email protected]:22101/1_88_1: Invalid data found when processing input

then i try to use Proxy with the help of RTSP server and it give me the error attached in server debug log

Config.yml

FFMPEG option

van:
   runOnDemand: ffmpeg -thread_queue_size 512 -i rtsp://admin:[email protected]:22101/1_88_1 -vcodec libx264 -preset veryfast -r 24 -g 2 -s 1280x720 -b:v 3000k -max_muxing_queue_size 4096 -f rtsp rtsp://127.0.0.1:$RTSP_PORT/$RTSP_PATH
   runOnDemandRestart: yes
   sourceAnyPortEnable: yes

Proxy option

  Vanp:
   source: rtsp://admin:[email protected]:22101/1_88_1
   sourceOnDemand: yes

Describe how to replicate the issue

  1. start server
  2. update config.yml
  3. request rtsp feed
  4. error appear

Did you attach the server logs?

yes / no

YES server.log

Did you attach a network dump?

yes / no NO

Tabarane avatar Aug 19 '22 10:08 Tabarane

Hello, please provide a network dump, that can be generated in this way:

  1. Download wireshark (https://www.wireshark.org/)
  2. Start capturing on the interface used for exchanging RTSP (if the server and the target software are both installed on your pc, the interface is probably "loopback", otherwise it's the one of your network card)
  3. Start the server and replicate the issue
  4. Stop capturing, save the result in .pcap format
  5. Attach

PS: when generating the network dump, use this configuration:

  Vanp:
   source: rtsp://admin:[email protected]:22101/1_88_1
   sourceOnDemand: no

Start the server, wait 30seconds, stop the server, stop recording the dump and attach the dump.

aler9 avatar Aug 27 '22 15:08 aler9

Attached as requested per instructions Vanp dump.zip server ip is localhost , interface ip from windows machine is 10.10.101.109

loopback dump Vanp dump 2 loopback.zip

ps: after like 3 or 4 attempt the feed worked but after trying again it kept failing as before

Tabarane avatar Aug 27 '22 20:08 Tabarane

Hello @Tabarane, thanks for providing the dumps, i finally found the issue. The server wants to pull the video stream from the camera with the UDP transport protocol:

[path Vanp] [rtsp source] c->s SETUP rtsp://172.17.172.145:22101/1_88_1/trackID=0 RTSP/1.0
Authorization: Digest username="admin", realm="Server", nonce="852167", uri="rtsp://172.17.172.145:22101/1_88_1/trackID=0", response="4ad478cdf926557eae6b82f0d4dbe90e"
CSeq: 4
Transport: RTP/AVP;unicast;client_port=65360-65361;mode=play
User-Agent: gortsplib

The camera accepts the request, but it replies with a response fit for the TCP transport protocol:

RTSP/1.0 200 OK
CSeq: 4
Session: WsDeuODg
Transport: RTP/AVP/TCP;unicast;source=172.17.172.145;server_port=22101;interleaved=0-1;ssrc=2A3B4C5D
X-Dynamic-Rate: 1

And subsequently starts sending the stream with the TCP transport protocol, causing this error:

[rtsp source] ERR: expected 'RTSP/1.0', got [36 0 0 27 128 96 0 0 0 0 17 148 42 59 76 93 103 66 0 41 141 141 64 90 30 208 15 8 132 83 128 36 0 0 16 128 96 0 1 0 0 17 148 42 59 76 93 104 202 67 200 36 0 5 120 128 96 0 2 0 0 17 148 42 59 76 93 124 133 136 128 0]

and this error in ffmpeg:

[rtsp @ 000001c44d179e80] Nonmatching transport in server reply rtsp://admin:[email protected]:22101/1_88_1: Invalid data found when processing input

rtsp-simple-server and gortsplib need to be improved in order to detect TCP responses to UDP requests and switch protocol from UDP to TCP.

aler9 avatar Jan 18 '23 15:01 aler9

@aler9 Thanks man, i hope im helping the project to improve , im using it since 2020 and its has been AMAZING, some challenges related to proxy type but not that BUG level yet )))

Tabarane avatar Jan 18 '23 16:01 Tabarane

@aler9 Working like a charm in proxy mode , amazing man, still FFMPEG has raised error with non matching transport, but Proxy mode is like wow :))) i have such type of issue when proxy with GARMIN VIRB 360 , if you interested i can gather logs for you , i always use very strange type of cameras and drones for my work and SRTSP is an Vital for me

Tabarane avatar Jan 18 '23 20:01 Tabarane

If you have other problematic devices, feel free to open additional issues. Meanwhile, this is fixed.

aler9 avatar Jan 19 '23 09:01 aler9

added in v0.21.2

aler9 avatar Jan 26 '23 10:01 aler9

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.

github-actions[bot] avatar Jul 31 '23 15:07 github-actions[bot]