Sunday, 11 August 2019


A practical example of using the RTSP protocol via the cloud

Let's talk about a practical example of using the RTSP protocol for CCTV.
Imagine a situation where you have some analog security cameras connected to a digital recorder (DVR) and your intention is to have redundant video recordings. You just need to choose a service that allows you to store everything on a server in the cloud (somewhere in the Internet).
There are several cloud services available in the market such as CamCloudCameraFTP, and Angelcam and you can choose the one that best suits your needs.
In this example I will use the services of Angelcam that works with different device brands and also work well with the RTSP protocol.
==> For more details, I recommend reading the other lesson: CCTV camera cloud recording: Using online IP camera storage

Configuring the router to work with the cloud

Before doing the tests with the command in the cloud, it is necessary to configure the router, this procedure is extremely simple, just use the IP information and port of the IP camera.
Basically, you have to inform the router that it should direct traffic coming from the Internet to the IP camera whenever the request is to a particular logical port which in the case of the RTSP protocol is by default the 554 .
See the image below that shows the configuration of the router, note that the configuration for this model must be made in the "Applications and games" menu the IP camera address is 192.168.2.107 and the port is 554.
Obviously you will have to look for other menus in different models of routers, usually you find this menu as port forwarding, port forwarding or NAT.

How to configure the cloud server

Dahua DVR can work seamlessly with this service because it allows the use of RTSP command and the information we need for configuration is available in the product's manual.
In this specific case, the device is a 4-channel Dahua DVR that uses the following RTSP command:
rtsp://<IP>:<Port>/user=<username>_password=<pass>_channel=<channel>_stream=0.sdp?real_stream
Just use this command and replace the IP, port, user and password information and that's it, everything will work according to your network. Everything must be configured on the server side of the cloud and the routing rules must be ready on the router that is on your local network.
See in the following image an example of how to configure the Angelcam's cloud. After creating a platform account in the site https://angelcam.com login with the user and password and choose the option DVR and NVR.
After this step simply type or paste the RTSP command as shown in the following image
Note that the command used includes the external IP used by the router and the 554 port that was used in the router configuration and which is the DVR standard.
It is important to understand the concept, the RTSP command sent by the cloud server arrives at the router through the external interface before being routed according to established rules and therefore, you must make sure which is the external IP of the used by the router.
The following image shows the end result of the camera connection to the server in the cloud.
In some cases you will notice that the image may suffer some quality variations due to some factors such as lack of Internet link stability, available bandwidth reduction or incompatibility of commands between the cloud server or camera.
Be sure to upgrade the IP camera firmware to the latest version available, this helps maintain compatibility with systems that use RTSP as cloud services and other brand recorders.

If you do not have a static IP on your Internet link

If you do not have a static IP on your Internet link, you can use a DDNS service available on the Internet, so the cloud service will continue to work and record the images from your camera even when there was an automatic change of the external IP of your router.

How to find your IP camera's RTSP command

The simplest way to find the command used by your camera or recorder is to consult the product's manual, if this is not possible contact your equipment supplier, if you still have problems you may try to use the ONVIF DEVICE MANAGER software following the instructions from the lesson ONVIF Device Manager Review and Download (Test IP Cameras)

Final considerations

Now you already know what the RTSP protocol is and how you can do the tests and use it in practical situations.
I recommend that you run local tests with the VLC software and the devices you have on your network to familiarize yourself with the use of this protocol

How to choose the correct power supply for your CCTV camera

To connect the CCTV cameras it is necessary to use a power supply that provides the voltage and the proper current according to the project.
In this lesson, you will learn how to choose the correct power supply for your surveillance camera, just keep reading.
In most modern installations with analog cameras, the power supply is centralized and distribute power to all installed cameras.
Below is an example of a centralized power supply, this type of power supply can be used to connect multiple cameras according to their maximum current.
The connection is extremely simple because there are labels on each of the connectors, the power supply must connected to an electrical outlet using the hot and neutral connectors, and the positive and negative connectors are connected to the cameras. There is also a connector for grounding.
It is recommended to use a power supply with 80% of its maximum capacity to avoid any overload problems. When the system is turned on, there is an initial peak current that can compromise the source if it is too close to the full capacity.
For a CCTV project, it is necessary to know which current (amperage) each camera consumes, so you can use the appropriate power supply.
This information is on the camera label or in the installation manual, in some cases, instead of the current, we find the power information in W (watts), so just do the conversion through a simple division calculation.
Below is an example of a camera that shows the power in Watts and the voltage (V), from there we can calculate which is the current that will be used.
Now that we know how much current is needed for one camera, just do the same for the others and add up the total of cameras that will be used in the project to calculate the necessary power supply, and remember to use 80% of the capacity.

Choosing the correct power supply for a group of CCTV cameras

Suppose we have 16 cameras that will be installed in a DVR and assuming that the source will be used only for the cameras, since the recorder has its source apart, we do the calculations below:
16 camera at 0.35A (350mA) each: 
​16 x 0.35 = 5,6A

Considering the maximum 80% capacity:
5,6 / 0,80 = 7A
Is necessary to have a 7A power supply for a 16 cameras project
With a 7A power supply we can connect the cameras as shown in the image below
Repeat the process for the other cameras, splitting between the other connectors that have not yet been used. In the example above there would be 8 cameras in each pair of connectors (V- V+). In practice it is best to buy a power supply that has more connectors available to make the installation easier and organized.
There are other professional power supplies that allow the connection of each camera to its own fuse-protected and LED post that indicates if the camera is powered. See the example in the image below:
This is a centralized 12VDC and 10A power supply with individual terminals for connecting up to 18 cameras. The fuses are PTC type that open as there is a high current that heats the circuit and closes when it ceases the passage of the current, so it resets itself without needing to be replaced.
A power supply like this allows the connection of 18 cameras with maximum consumption of 500mA each. (10/18 = 0.55). That would be enough for our previous example with 16 cameras that consume 350mA each.
Quick recap: 16 cameras x 350mA --> Calculation: 16 x 0.35 = 5,6A
80% maximum power supply usage --> Calculation: 6,3 / 0,80 = 7A
The image below shows the installation of 16 cameras using a power supply that allows to connect each one individually.
Good quality power supplies allow voltage variation to compensate for cable losses or high voltage that can reach the camera
A good CCTV camera can work with 10% variation in power, so we can use a potentiometer like the one shown in the picture to vary the voltage for more or less voltage.
With a variation of 10% down, we have the voltage at 10.8V and with variation of 10% up we have the voltage at 13.2V. Both are enough.

Conclusion

Now you have enough information to choose the correct power supply for your CCTV cameras, it's just a question of do some basic math to calculate the voltage and current necessary to your cameras.
You also need to choose the correct coaxial cable for the installation, so I highly recommend you to read the lesson Best coaxial cable for CCTV.

How to connect a PTZ camera to a DVR

If you want to learn how to connect a PTZ camera to a DVR, I got to tell you that you are in the right place. 
In this lesson you are going to learn how to identify the DVR and the PTZ camera physical connectors, how to wire them properly and how to setup the devices by using the RS-485 standard and the correct protocol (Pelco P or D).
Here are the steps to connect a PTZ camera to a DVR:
1. Identify the physical RS-485 connector in the camera;
2. Identify the physical RS-485 connector in the DVR;
3. Run the wire between the DVR and the PTZ;
4. Set the dip-switches on the camera to chose the parameters;
5. Log into the DVR and setup the PTZ parameters.
==> Just keep reading to understand all the details...

How to control a PTZ camera

PTZ cameras have an internal motor to control the position of the lens that can move horizontally (known as PAN) or vertically (known as TILT) and there's also a motor to control the optical ZOOM.
By controlling the PTZ movements, an operator can patrol a certain location by sending commands using a controller (joystick), a DVR (Digital Video Recorder) or software installed in a computer located in a remote monitoring center. 
To send the commands,  it is necessary to connect a two-wire cable (positive and negative) from the back of the DVR to the PTZ camera. 
In this example, the cameras are connected to the DVR with a twisted pair cable that sends the commands through a universal connection standard and a protocol that the camera and the DVR have in common (such as Pelco P or D).
The twisted pair wires must be connected to the back of the DVR into the RS-485 connector.

The RS-485 PTZ control standard

By using the RS-485 standard with twisted pair cables, it is possible to send commands to the camera at distances up to 1,200m (3,937 feet) and multiple cameras can be connected to the cables in a serial line.
In the image below, it is possible to see the connector used for the command via RS-485. Note that they are labeled “positive and negative”.
Depending on the model of the equipment, these labels may be different, there are DVRs and cameras that show: TX + / TX- or RX + / RX-.
TX is the transmitter and RX is the receiver. If we follow the logic, the DVR should be the TX that transmits the commands and the RX camera that receives the command.
The important thing to keep in mind is that positive and negative wires should be properly connected to the DVR and to the camera. The device’s manual has the instructions for that and not all manufacturers follow a standard for the names.
In addition to the physical connection using the RS-485 standard, it is also necessary to configure the camera ID and the communication protocol that will be used between the devices.
This communication protocol is developed by the manufacturer itself, so if the DVR and camera are from the same manufacturer there will be no problems, but if they are from different brands we must use a universal protocol.
There is a universal protocol called Pelco P and another called Pelco D, they are available in cameras and DVRs from different manufacturers, so if we have different brands of equipment we can use this protocol.

The Pelco-P and Pelco-D protocols

Pelco is a large camera manufacturer that created this communication protocol for PTZ cameras. This standard became popular among system integrators, so other manufacturers besides having their own protocols, also let Pelco's protocol available on their equipment for compatibility.
When both devices (PTZ and DVR) are manufactured by the same company they usually use the same protocol, so there's no need to use Pelco's.
On situation, where the devices have different brands, it is necessary to choose the common protocol between them, in this case Pelco P or D for example.
A PTZ camera usually has a switch where you can choose the protocol.
This is an example of how a camera's protocol is configured. A small arrow can be rotated to a specific position in which a number or letter represents the protocol.
Using a table from the camera manufacturer's manual you can choose the protocol that will be used, as shown in the illustration below:
SW3
Protocol
Baud rate
0
Samsung
9,600
1
Samsung
19,200
2
Pelco D
2,400
3
Pelco D
4,800
4
Pelco D
9,600
5
Pelco D
4,800
6
Pelco P
9,600
7
Samsung E.
9,600
8
Samsung E.
19,200
9
Panasonic
9,600
A
Panasonic
19,200
B
Vicon
4,800
C
Vicon
9,600
D
Honeywell
9,600
E
AD
4,800
F
Bosch
9,600
In the table you can find the manufacturers and their respective protocols and data such as communication speed (Baud Rate).
The configuration is very simple, just follow the table orientation and choose the protocol you want to use, in the case of this manufacturer the arrow positioned at number 6 indicates that the camera is configured to use Pelco P protocol with Baud Rate 9,600
It is also necessary to configure the DVR with the same parameters used in the camera.
In the above example, the parameters have been configured on the camera using a system with a rotating arrow, other cameras may, howeve,r have a set of small switches known as "Dip Switches" that can be placed in the "on and off" positions to obtain the desired setting.
A table for the correct combination of these switches ("Dip Switches") can also be found in the camera manufacturer's manual.

How to setup the DVR for PTZ control

See below a Pelco-P protocol configuration example for a DVR, just go to the PTZ menu and search for these settings for each of the cameras.
Other parameters such as Data Bit, Stop Bit, Parity, and Flow Control may appear on the menu.
In the menu above that the DVR has several types of protocols from different manufacturers that can be different according to each brand.
Not all DVRs will have these protocols that we see in this menu, but they will all have the Pelco protocol that is easily found in other manufacturers' equipment, so use it by default when you want to set up a different brand’s devices.

Conclusion

I hope you could learn how to connect a PTZ camera to a DVR, the next step is to test in your devices. Just apply the concept that you've learned here.
It's important to read the device's manual to make sure you are using the right protocol, baud rate and everything else.




How to measure bandwidth for IP cameras

In CCTV projects it is necessary to know how to measure bandwidth usage, especially if there is a need for transmission for remote monitoring via cell.
In this lesson, you will learn how to measure bandwidth usage for IP cameras and recording systems through the use of simple software.

Bandwidth measurement unit

The first thing you should learn is which units that are used to measure the speed of data traffic in digital networks.
When we talk about bandwidth usage for IP cameras or any other digital system that transmits data via a computer network or the Internet, we have to know how to quantify the amount of data that is transmitted or received per unit of time and in this case, we are talking about bits per second.
Do not worry too much about the term bit, it is the digital information unit represented by 0 or 1, at that point you just need to know that this term is basically the information that is transmitted over the network and the larger the number of bits to be transmitted the higher is the necessary bandwidth.
See the following image where there is an IP camera connected to a PoE injector that feeds the camera which in turn is connected to the laptop. An amount of data (bits) travels from the IP camera to the laptop and the bandwidth can be measured through the use of specific software.
When transmitting video from an IP camera to a recorder or to a mobile phone on the Internet, we use terms such as 256 Kbps500 Kbps1 Mbps, etc.
These numbers are referring to the amount of information that is transferred every second between the devices.
When we say that the baud rate is 256 Kbps, that means that 256,000 bits are transmitted every second, since K represents 1,000 and we could even write in another way, such as 256,000 bits per second, but that only makes things more difficult, so it's better to write or say 256 Kbps (256 Kilobits per second).
Similarly, we can use M to represent 1,000,000 (one million), so when we say that the speed of the network link is 1 Mbps, we are in practice saying that it is possible to traffic 1 million bits every second through this link.
==> To learn more, read the lesson: What is bitrate of IP camera.
So we must measure bandwidth usage at specific points in our network to ensure that the system will work without crashes if the available bandwidth is not enough we have to use faster network/Internet links or reduce the amount of bandwidth that travels through the system.
The following image shows an IP camera connected to a router that in turn is connected to a laptop and an NVR. You need to know how much bandwidth is used between the IP camera and all devices, as well as the Internet link traffic.
When installing an IP camera, you can see how much bandwidth is consumed according to the video streaming quality setting of the camera, because the higher the quality (resolution, frame rate per second and compression) the greater the use of the bandwidth.
Other factors like the amount of movement in front of the camera can also influence the bandwidth usage result, so it is important that you do the calculations and tests to be sure of the bandwidth requirement for your project.
See in the image below an example of an IP camera that shows the maximum amount of bandwidth that will be used is 2,048 Kbps (2 Mbps) to deliver the video at a resolution of 1920x1080 at a frame rate of 15 FPS and intermediate compression using the  H .264 CODEC.
This information is provided by the IP camera itself as shown in the picture above (the menu varies according to the different makes and models) and can be verified by measurement with software installed on a computer.

 

How to measure the bandwidth usage with the Windows task manager

If you do not have any specific software to measure the bandwidth usage of your IP camera, you can use the Windows task manager by right-clicking on the bottom bar and choosing the "task manager" in the floating menu.
In the network menu, you can view the amount of bandwidth used at the moment, note in the following image that the IP camera was accessed via the Internet Explorer and the task manager shows that the camera is using 1.6 Mbps of traffic.
This is a very simple and practical way of measuring the bandwidth usage of an IP camera, once the camera image is being displayed on the computer this traffic can be measured.
Be careful when measuring network traffic as there is an option to measure what is coming in through the Ethernet interface (to which the network cable is connected) since there is another option to measure network traffic over the Wi-Fi interface, so please don't get confused.
Make sure you are measuring the correct interface and that there is no other traffic than the camera being used, otherwise the measurement will not be correct

Measuring the IP camera bandwidth usage with a professional software

You can use professional software for measuring bandwidth usage, there is a multitude of them available on the Internet, some are free and others are paid.
I use Netlimiter to analyze the network traffic because it allows you to view bandwidth usage per application, ie it is possible to know that Internet Explorer, Google Chrome, monitoring software or any other bandwidth are using individually.
Note in the following image that the software shows the amount of network bandwidth being used by Internet Explorer which is connected to the IP camera.
It is recommended that you use professional software to measure the use of networks in IP CCTV systems, so you can have more control over what is being used in your network.
Netlimiter is able to identify the processes that are using network bandwidth and what are the device ports, which is very useful for diagnosing potential problems.

How to Measure Your Internet Bandwidth

After measuring the bandwidth usage of the devices, it is necessary to ensure that there is Internet bandwidth required for external traffic if you want to view the cameras remotely via mobile.
Measuring Internet bandwidth is extremely simple, just use the Speedtest.net service by typing the address https://speedtest.net into an Internet browser such as Google Chrome or Internet Explorer.
See below an example of Internet bandwidth measurement where a link is being used with 59 Mbps download and 58 Mbps upload.
Obviously, it is not recommended to send high-resolution video streaming over the Internet for mobile viewing as this will consume the resources of your Internet link unnecessarily, after all the display of the image on the screen of the mobile phone does not require high-resolution video such as a Full HD .
For mobile video streaming over the Internet, you can create a profile with low resolution and low frame rate, and high video compression.
Most IP cameras have at least two video configuration profiles, so they can be used with a high-quality profile for local recording and the other profile must be configured with low quality for remote sending to a cell phone.

Summary and conclusion

Measuring the use of network bandwidth in IP cameras is not complicated and the same concept applies to digital recorders (DVRs) and network recorders (NVRs).
Just use the features available in the device menu itself or use the software on the computer or laptop that must be connected to the same network.
If you do not want to buy bandwidth analysis software, use the Windows task manager itself,  make sure not to mix network traffic from other sources.
Ensure that you have enough Internet bandwidth to stream video to a mobile.
I hope you enjoy the information in this lesson and please click the button below to share it with your friends.

What is RTSP protocol for IP cameras

The RTSP protocol can be used to transmit images on CCTV systems and due to its compatibility with several devices, it is a great option for hybrid projects.
In this lesson, you will learn what the RTSP protocol is and how to use it for an IP camera, digital recorder (DVR) or network recorder (NVR).

What is the RTSP protocol?

RSTP is an acronym for "Real Time Streaming Protocol", meaning it was designed to send audio or video live from one device to another.
This protocol was not created exclusively for CCTV, it was already used in other sectors where there is a need for real-time transmission and was adopted by video surveillance device manufacturers and became a standard protocol.

The RTSP protocol for CCTV

Video surveillance manufacturers implement the RTSP protocol on their cameras, recorders, and software so that they are compatible with other devices that are available in the market.
When purchasing an IP camera and a video network recorder from different manufacturers, you can have them communicate using this universal protocol.
To configure the equipment it is necessary to find out which RTSP command is to be used and this information can be found in the product's manual or by consulting the technical support team.

How to use the RTSP protocol

Imagine that you have purchased an IP camera from Dahua (a Chinese manufacturer) and want to use it with a network recorder (NVR) that you already own, but it is from a different manufacturer, such as Samsung.
You should search the Dahua's camera manual for the RTSP command that should be used to stream video over the network.
If you do not find this information in the product's manual you should contact the manufacturer technical support team as it is essential that you get the correct command so your equipment can communicate with each other.
After obtaining this information, you must insert it into the recorder which will initiate a request to send video through this universal protocol.
In practice, just open the NVR menu and input the RTSP command followed by the username and password of the IP camera and upon receiving this information the camera will send a real-time video stream.

How to use the RTSP protocol for cloud recording

The principle for video recording in the cloud is the same, just use the correct RTSP command to request the camera to send the video to the server that is located somewhere on the Internet.
The diagram below shows a IP camera that is installed on an internal network and it is connected to a router. You just need to set up the cloud recording server to send the RTSP command over the Internet and as soon as it is received by the camera it starts video streaming.
In this example, the server simply sends the RTSP command over the Internet and upon reaching the external interface of the router it routes to the internal network where the camera is located.
Therefore, it is necessary to configure the router and input the routing rules that are based on the network interfaces and communication ports.

How to Test an IP Camera with the RTSP Protocol

Before trying to set up a CCTV system it is interesting to make sure everything will work properly and the best way to do this is through simple tests like connecting an IP camera with a traditional software that uses the RTSP protocol.
There is a traditional free software called VLC that can be used for such tests. The diagram below shows an example of how to use it.
In this example, an IP camera is connected to the router which in turn is connected to the laptop that uses the VLC software to send the RTSP command to the camera. Everything is on the local network and therefore there is no need for routing rules (the devices are attached to the internal ports).
In the VLC software, just open the "Media> Open Network Stream" menu or type CTRL + N and paste the RTSP command from the IP camera.
In our example, the IP of the camera is 192.168.2.107 and the RTSP port is 554, this information must be entered in the command that will be sent to the camera. See the example in the image below:
The command in this case is:
rtsp://192.168.2.107:554/user=admin_password=admin_channel=1_stream=0.sdp?real_stream
After sending the command you can see the image of the IP camera directly on the laptop, which proves that the command used is correct and the network connections and IPs are also correct.
After this initial test it is possible to move on to more advanced tests and use a remote connection with IP camera recorders or cloud recording systems.