Hikvision direct camera access using Virtual Host

Robert G.

Getting comfortable
Joined
Oct 6, 2018
Messages
257
Reaction score
500
Location
North America
I have HIKVision virtual host enabled on my DVR.

I know I can access cameras at some private address and port, something like this:


That will give me access direct to the camera GUI, I can also stream video from there. I believe the video streaming uses some type of browser plugin?

I have a Hikvision camera ( DS-2CD2347G1-LU ) that has a built in microphone. I can configure the camera to stream audio OR audio & video. It works, I can get audio both through the NVR or connecting to the camera at the virtual host address.

I do not want my DVR to process audio at all. So I have it set to stream only video. This also works, I get only video, no audio.

When I connect via the camera GUI ( ) I CAN still get audio. It is like the GUI is somehow establishing a connection direct to the camera and pulling the audio & video feed even if I have the setting in the DVR to stream only Video.

I have been trying to figure out how this is being done, as I want a backup DVR to connect which can record the sub stream & audio without my main DVR streaming the audio?

Does that make sense? Here is the setup I want in a child like photo.

sound.png


Essentially I want 1 DVR to record video only, and the other to record both video & audio. When accessing through the virtual host, I assumed no audio is possible because the DVR (the host of the virtual host) has audio disabled.

That rule does not stand true however, when I connect to the camera GUI directly (through the virtual host) using the plugin in the browser - which CAN pull audio.

Anyone know how I can get the audio when going through the virtual host address?
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
9,949
Reaction score
19,256
Location
Alabama
What about VLC?

FWIW, I use Blue Iris and not a NVR but I can stream RTSP from a cam and record the video and the audio directly from the cam using VLC.

This is the URL for my Amcrest (Dahua) cam; be sure to place 2 slashes after "rtsp" and the colon :
Code:
rtsp:/cam-username:cam-password@cam-IP:554/cam/realmonitor?channel=1&subtype=0
 

Robert G.

Getting comfortable
Joined
Oct 6, 2018
Messages
257
Reaction score
500
Location
North America
What about VLC?
Code:
rtsp:/cam-username:cam-password@cam-IP:554/cam/realmonitor?channel=1&subtype=0
I can connect with VLC, but I only know how to do it using the DVR. When using Hikvision virtual host feature, all cameras are on their own private network behind the DVR. In order to access them, you must connect through the DVR using a specific port. Something like this:

rtsp:/dvr-ip:554/Streaming/channels/202

In this case, rather than connecting directly to the camera I must go through the DVR. Since I have told the DVR to stream only Video, no audio comes through.

That makes sense, but I am curious how the browser plugin in able to get audio. I think it must have some way to connect to the camera directly, but I can't find any mention of it anywhere online.
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
9,949
Reaction score
19,256
Location
Alabama
I just thought you could configure your PC's NIC with a static IP in the same subnet as one of the cams (on the NVR's virtual host subnet) and with subnet mask of 255.255.255.0, no DNS's needed, plug the PC directly into one of the NVR's POE ports, open VLC and hit the cam with rtsp:/camera-IP:554/Streaming/channels/202 or the like.

Of course, 2 slashes after "rstp" and colon (forum won't allow 2 in a row).
 

trempa92

Getting the hang of it
Joined
Mar 26, 2020
Messages
171
Reaction score
43
Location
Croatia,Zagreb
Virtual host only redirects traffic to your camera over certain port, it is and will always be direct camera settings u see at GUI over there.
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
14,971
Reaction score
5,880
Location
Scotland
Virtual host only redirects traffic to your camera over certain port
Yes, here is an example of how it is implemented :
Code:
iptables -t nat -A PREROUTING -p tcp --dport 65001 -j DNAT --to-destination 192.168.1.100:80
iptables -t nat -A POSTROUTING -p tcp -d 192.168.1.100 --dport 80 -o eth1 -j MASQUERADE
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
9,949
Reaction score
19,256
Location
Alabama
Yes, here is an example of how it is implemented :
Code:
iptables -t nat -A PREROUTING -p tcp --dport 65001 -j DNAT --to-destination 192.168.1.100:80
iptables -t nat -A POSTROUTING -p tcp -d 192.168.1.100 --dport 80 -o eth1 -j MASQUERADE
So if I'm reading that correctly, a PC-based browser request from the same subnet to 192.168.1.100 will be directed to port 80, the default HTTP port for a cam at that same IP.
 

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
14,971
Reaction score
5,880
Location
Scotland
So if I'm reading that correctly, a PC-based browser request from the same subnet to 192.168.1.100 will be directed to port 80, the default HTTP port for a cam at that same IP.
Yes, that's correct.
That happens to be a camera on the same LAN as the NVR as opposed to being connected to an NVR PoE port, but Virtual Host works in the same way.
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
9,949
Reaction score
19,256
Location
Alabama
Yes, that's correct.
That happens to be a camera on the same LAN as the NVR as opposed to being connected to an NVR PoE port, but Virtual Host works in the same way.
That's what I thought but since I'm using Blue Iris VMS on a PC vs. having a NVR I just wanted to make sure. :cool:
 

user8963

Known around here
Joined
Nov 26, 2018
Messages
1,465
Reaction score
2,298
Location
Christmas Island
To my knowledge, the virtual host function do more than just let you access the camera via port.
Its the same if you want to setup email alerts for a camera (give internet access) which is inside the NVR POE network
Problem is that most customers are unable to setup a proper static route. Hikvision made it easy via different ports.

If you are network 192.168.10.0/24 and want to access 192.168.254.0/24 , your device is unable to find any device in the other network, so it ask the gateway (your router) where the device is. But if you havent setup a static route, then your gateway cannot tell where the device is.

Example:
your homenetwork is 192.168.10.0/24
The hikvision poe network is 192.168.254.0/24
the nvr ip is 192.168.10.100
your device is 192.168.10.200
the gateway is 192.168.10.254

So you have to setup a static route for 192.168.254.0/24 in your router and setup 192.168.10.100 as the gateway to the network.
If your device ask for lets say 192.168.254.50 , the float would be

192.168.10.200 <-> 192.168.10.254 <-> 192.168.10.100 <->(192.168.254.1) <-> 192.168.254.50

You have to setup a gateway on EACH camera manually, otherwise it wont work. It must be the poe network gateway as i remember. (192.168.254.1 if you havent changed the standard subnet)

The virtualhost function is more like a static route between the poe network and the lan network, but you have to setup a different route inside your home gateway to make it work.
For common setups you dont need any iptable forwards with the ports.

So you can just use NVR and rtsp directly from the cameras to blueiris or whatever at the same time
 
Last edited:
Joined
Jun 27, 2022
Messages
1
Reaction score
1
Location
uk
Wow, I didn't think you could use a Virtual Host for such purposes. Thanks a lot for providing us with new and comprehensive information. I thought VPS is done only for hosting miscellaneous servers. I guess that's because all that bothers me are PC games like CSGO or SAMP. It's unbelievable how sharply technologies evolve in every possible field. I wonder if I could use a VPS from tapleto-host.net. I would highly appreciate any advice you could provide, and I'm keenly waiting for some answers! Cheers.
 
Last edited:
Top