How does RTSP work?
RTSP works like a remote control for a video stream. The software that wants the video, called the client, connects to the camera or recorder and sends short text commands: OPTIONS asks what the device can do, DESCRIBE asks what streams it has, SETUP agrees how the video will travel, PLAY starts it and TEARDOWN ends it. The device asks for a user name and password before it answers DESCRIBE.
The video itself travels beside those commands as a series of small packets in a companion format called RTP, either over UDP or inside the same TCP connection as the commands. TCP resends anything lost and passes through routers and firewalls more reliably, which is why GoKavach uses RTSP over TCP.
RTSP only carries what the camera already produces, usually H.264 or H.265 video. It doesn't record, detect or store anything.
What does an RTSP URL look like?
An RTSP URL starts with rtsp:// and then names the user, the device's address, the port and a path that picks the camera and stream. A Hikvision recorder's first camera is typically rtsp://user:password@192.168.1.64:554/Streaming/Channels/101. A Dahua recorder uses a path such as /cam/realmonitor?channel=1&subtype=0. The path is different for every maker, which is the part people get stuck on.
The guide to finding your RTSP URL lists the formats, and the page on RTSP cameras covers brands without a preset. The last digit or the subtype usually chooses between the main stream and the sub stream.
How do you read an RTSP address part by part?
Take rtsp://viewer:Shop%402024@192.168.1.64:554/Streaming/Channels/301, the third camera on a Hikvision recorder. Each part answers one question.
- rtsp:// says which protocol to speak, the way https:// does for a web page.
- viewer:Shop%402024 is the user name and password. The password here is Shop@2024; an @ inside a password is written as %40 so it isn't mistaken for the @ that ends the login.
- 192.168.1.64 is the recorder's address on the local network. From outside the building this becomes the site's public IP address or a hostname.
- :554 is the port. It can be left out when the device uses 554.
- /Streaming/Channels/301 is the path. On this firmware the first digit is the channel and the last two pick the stream, so 301 is camera 3's main stream and 302 its sub stream.
Where will you meet RTSP as a CCTV owner?
You meet RTSP the first time you connect your cameras to anything other than the maker's own app: a video player on a computer, a different recorder, or a monitoring service. On most wired DVRs, NVRs and IP cameras it is switched on already. On some it is a tick box in the network settings, and a few consumer cameras don't offer it at all and only work through their maker's app.
In a recorder's menu it usually sits under the network settings, on a page listing the device's ports: an HTTP port for its web page, an RTSP port showing 554, and one or two ports for the maker's own software. That page is where you check the number or change it.
How is RTSP different from ONVIF, HTTP and the maker's app?
They do different jobs on the same device. HTTP, usually port 80, serves the recorder's settings pages to a browser. ONVIF is a standard for finding cameras on a network and changing their settings, and it hands over to RTSP when the picture itself is needed. RTSP delivers the live video and nothing else.
The maker's phone app normally uses none of these directly. You scan a code on the recorder and the app reaches it through the maker's own servers. That is convenient, but it gives you no address that other software can open, which is why a camera that only works through its app can't be read by anything else.
What are the common RTSP problems and how do you recognise them?
Most failures fall into four kinds, and the error tells you which.
- Asked for the login again, or error 401: the user name or password is wrong, the account is locked after too many tries, or a special character in the password needs encoding.
- Not found, or error 404: the device answered but the path is wrong for that brand, or the channel number doesn't exist.
- Times out with no answer: the address or port is wrong, RTSP is switched off, or from outside the port isn't forwarded.
- Opens, then the picture breaks up or freezes: packets are being lost, common over UDP or a weak link. Switching the player to TCP or choosing the sub stream usually steadies it.
What should you ask an installer about RTSP?
Ask five things, and write the answers down: whether RTSP is enabled on the recorder, which port it uses, the recorder's brand and model, its address on the local network, and a user name and password that can view live video. Many recorders let the administrator create a second user limited to live view. That is the account to give to outside software, so the administrator password stays private.
If the installer set up remote viewing, also ask whether the RTSP port is forwarded on the router and under which outside number. Installers often forward only the port their own app needs.
How does GoKavach use RTSP to send alerts?
GoKavach reads each camera's RTSP stream over TCP and checks a picture from it every few seconds. You choose the recorder's brand and type its address and login, and it builds the path: the main stream on Hikvision and Prama, the sub stream on Dahua, CP Plus and Honeywell. If the first format doesn't connect, the other of the Hikvision and Dahua formats is tried automatically. You can also paste any RTSP URL. Camera addresses are stored encrypted.
The address has to be reachable from outside the building, either by port forwarding or, with no router changes, through the site connector described in adding AI to existing CCTV. If a stream stops answering, a camera offline alert follows after the delay you set.