0

I am trying to connect to an IP camera using Onvif. This camera is not in my network and has been made available to me through an external IP address. When using the 'GetStreamUri' function I get a RTSP link with the internal IP address of the camera, this will not work. When I replace the IP manually it works just fine.

Does anybody have any other suggestions on how to handle this? Replacing the IP manually works but is not a very nice solution.

1 Answers1

1

A camera behind NAT and with RTSP streaming in general cannot be viewed from Internet, because you'll end up with all the classic problems related to NAT and VOIP (voip uses RTSP as well as ONVIF).

But you have a possible solution: configure the camera so that it streams over HTTP. At this point you should get a URI that should be accessible from Internet. In fact, if you invoke GetStreamUri, the camera will still return you an internal IP address, since it does not know that the router is configured for NAT. If you are lucky enough, the URI will be on port 80, thus by replacing the internal IP address with the external IP address of the gateway you should be able get the video.

Ottavio Campana
  • 4,088
  • 5
  • 31
  • 58
  • Hi Ottavio, We forwarded port 554 for RTSP and replaced the internal IP with the public IP as configured in the router like I described. I hoped there would be a better solution than replacing the IP manually but it seems like this is the only solution. Thank you for contributing. – Niels de Schrijver Jun 07 '17 at 10:06
  • What you propose is not a valid solution: the SDP returned by the DESCRIBE command is probably wrong (it'll show the internal IP address) and you'll need to open other ports, which may be dynamically chosen. the only reliable solution is configuring the camera to stream over RTP/RTSP/HTTP/TCP and hoping that it does not use a port different from 80 . – Ottavio Campana Jun 07 '17 at 14:34
  • Does anyone have a working piece of code getting the streaming url from the IP cam?? (Using authentication and everything you need to get a good response from your http xml post) – LoukMouk May 09 '18 at 19:01