How to setup and configure the RTSP stream with port forwarding
Why do we need port forwarding?
Most IP cameras operate in the Local Area Network. To make them accessible by a 3rd party vendor, we should apply port forwarding between ports on a static IP and cameras' RTSP stream ports.
Static IP must be accessible by the entity you'll stream to.
Let’s say our static IP is 38.142.141.11
What do we need?
- An RTSP supported IP Camera - RTSP stands for Real-Time Streaming Protocol.
- A static IP on your router - This can be provided by your Internet provider
- A port on the provided static IP - Different port for each camera
- RTSP Stream URL structure - Different for each brand
How do I configure port forwarding?
- Go to the router interface
- Open the port forwarding section in the router
- Most of the routers’ port forwarding panel can be found in this website https://portforward.com/router.htm
- Give a name for the description - Warehouse 2 / IP Cam 1
- Specify the IP addresses of each camera will be connected. Let’s say 192.168.1.11
- Set the protocol section TCP/UDP
- The external port is the port will be addressed on static IP. So it can be chosen as any empty port on the static IP. Let’s say port 5001. So set both external ports as 5001 - 5001
- The internal port is the port in which the RTSP stream will be published from the IP Camera. Port number 554 is the RTSP stream port for nearly all IP cameras. So let’s set 554 - 554 as the Internal Port
- Add the forwarding rule to the list
In the end, the port configuration on the port forwarding section of your router will look like this.
Now when you connect 38.142.141.11:5001 the actual address you’re reaching will be 192.168.1.11:554
You can use telnet command on your computer’s terminal to test if the camera’s RTSP port is accessible
Telnet 38.142.141.11 5001
If the response is an escape character the connection is OK. If nothing happens that means there is a problem with
- the port forwarding
- or static IP
How do I find my camera’s RTSP URL
When the telnet response indicates that the RTSP port of the camera is accessible next step is building the RTSP URL for the system we will stream to.
Finding the right RTSP URL structure is the most challenging part because it is different for each brand and model. But don’t worry, you can find it in less than 10 minutes with a Google search. Could not find it? You can raise a support ticket to your camera provider or write to us. We’re here to help :)
Here are some examples
- HikVision
rtsp://admin:admin123@38.142.141.11:5001/Streaming/Channels/101/ - Bosch
rtsp://38.142.141.11:5002/rtsp_tunnel
Once the RTSP URL is generated it can be tested with software like on VLC
How do I test my RTSP URL?
- Download VLC media player
- Open VLC
- Click on the File menu
- Select Open Network
- Paste the generated RTSP URL to the URL textbox
- Click Open
The video stream will start in less than 10 seconds
Can I test the RTSP stream via the terminal window?
1. Open your terminal
2. Install FFmpeg
brew install ffmpeg
3. To test the accessibility run:
ffprobe rtsp://admin:admin@38.142.141.11:5001/Streaming/Channels/101/
4. To play the video stream run:
ffplay -rtsptransport tcp rtsp://38.142.141.11:5002/rtsptunnel