Foscam Live Feed URL: RTSP and Snapshot Links for VLC and Home Assistant

Foscam cameras come with their own app, but if you want to view the camera in VLC, record it with an NVR like Agent DVR or Frigate, or add it to Home Assistant, you need its live feed URL. Foscam doesn't make these easy to find, so here they are, along with how to test them and keep them secure.

The RTSP live stream URL

Most current Foscam HD cameras stream over RTSP using this format:

rtsp://USERNAME:PASSWORD@CAMERA-IP:88/videoMain

Replace USERNAME and PASSWORD with a user account on the camera, and CAMERA-IP with the camera's IP address on your network. Foscam cameras provide two video streams plus audio:

  • /videoMain: the main, full-resolution stream. Use this for viewing and recording.
  • /videoSub: a lower-resolution sub stream. It's much lighter on your network and CPU, which makes it ideal for motion or object detection, or for viewing on a phone.
  • /audio: audio only, on models with a microphone.

Which port?

Most Foscam HD models use port 88 by default for both the web interface and RTSP. Some models use 554 (the standard RTSP port) or another number instead. You can confirm yours by logging into the camera's web page and checking the port settings under the network section.

The snapshot (still image) URL

To grab a single JPEG image from the camera, for example for a dashboard or a notification, use:

http://CAMERA-IP:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=USERNAME&pwd=PASSWORD

Older Foscam models

Older, lower-resolution Foscam cameras (the original MJPEG models) don't use these URLs. They usually serve video over HTTP on port 80 instead, with addresses like:

http://CAMERA-IP/videostream.cgi?user=USERNAME&pwd=PASSWORD
http://CAMERA-IP/snapshot.cgi?user=USERNAME&pwd=PASSWORD

If the RTSP URL doesn't work on an older camera, try these.

Testing the URL in VLC

  1. Open VLC and choose Media > Open Network Stream.
  2. Paste in your RTSP URL with your details filled in.
  3. Click Play. The live feed should appear within a few seconds.

If VLC works, you know the URL, port and login are right, and any remaining problems are in the app you're adding it to.

Adding the camera to Home Assistant

There are two ways to do it:

  • The Foscam integration: go to Settings > Devices & services > Add integration, search for Foscam, and enter the camera's IP address, port, username and password. It sets up the live view for you.
  • The Generic Camera integration: add Generic Camera instead and paste in the snapshot URL as the still image URL and the RTSP URL as the stream source. This works with almost any camera, including older Foscams.

Security tips

  • Create a separate user for streaming. Don't put your admin login into other apps. Most Foscam cameras let you add a lower-privilege user just for viewing.
  • Keep cameras off the internet. The username and password in these URLs are easy to intercept, so don't forward the camera's ports on your router. For remote viewing, use a VPN or your NVR or Home Assistant's own secure remote access instead.
  • Give the camera a fixed IP address with a DHCP reservation on your router, so the URL doesn't stop working when the address changes.
  • Keep the firmware up to date using Foscam's app or web interface.

Troubleshooting

  • Login error or 401 Unauthorized: check the username and password. If your password contains special characters such as @, : or #, they must be URL-encoded (for example @ becomes %40), or change the password to letters and numbers only.
  • Connection refused or timed out: the port is probably wrong. Check the camera's port settings.
  • Works in VLC but stutters in another app: try the /videoSub stream, which uses far less bandwidth.
  • Black screen or dropped connections: cameras like these can only handle a limited number of streams at once, so close other viewers and try again, or restart the camera.

Comments

Popular posts from this blog

How to Connect a Raspberry Pi Pico W to WiFi with MicroPython

How to Blink an LED on the Raspberry Pi Pico and Pico W (MicroPython)