← All How-To Guides
Camera setup

How to Connect Hikvision Cameras to LightNVR

Translate Hikvision channel and stream numbers into RTSP URLs, verify them locally, and add the main and sub streams to LightNVR.

9 min read Difficulty: Beginner

1. Before you start

This guide assumes the camera is already powered, activated, and visible on your local network. Complete the RTSP test from a computer on that same network before involving a VPN or cloud recorder. That separates a camera configuration problem from a routing problem.

You will need:

  • The camera’s local IP address
  • A camera-local username and password with live-view permission
  • A computer with VLC or ffprobe for the local test
  • Network access from LightNVR to the camera, directly or through a private tunnel
Check the model first. The same URL scheme is used across many Hikvision cameras, NVRs, DVRs, and encoders, but channel numbering on an NVR may not match the physical port label. Verify the channel number in the Hikvision interface.

2. Prepare the Hikvision camera

  1. Find the device IP and RTSP port: Use SADP, the camera web interface, or your router lease list. In the Hikvision web interface, check Configuration, Network, Basic Settings, then Port. RTSP is commonly 554.
  2. Confirm stream encoding: Under Configuration, Video/Audio, select channel 1 and set the main and sub streams. H.264 is the simplest format for an initial compatibility test.
  3. Create a recording user: Use a dedicated camera account with live-view permission rather than embedding the administrator account in the RTSP URL.
A DHCP reservation is enough; the camera does not need a manually configured static IP. The goal is simply to keep its address from changing underneath the recorder.

3. Build the main and sub-stream URLs

Replace the placeholders with the camera account and reserved local IP address.

UseRTSP URL
Main recording streamrtsp://username:password@CAMERA_IP:554/Streaming/Channels/101
Lower-bandwidth live streamrtsp://username:password@CAMERA_IP:554/Streaming/Channels/102

The final digits combine channel and stream. 101 is channel 1 main stream (01); 102 is channel 1 sub stream (02). On an NVR, 1701 is channel 17 main and 1702 is channel 17 sub.

If a username or password contains reserved URL characters such as @, :, /, ?, or #, percent-encode that value before embedding it in the URL. Do not weaken the camera password just to make the URL easier to type.

4. Test the feed locally

Quick visual test with VLC

  1. Connect the test computer to the same network as the camera.
  2. In VLC, choose Media → Open Network Stream.
  3. Paste the main-stream URL and select Play.
  4. Repeat with the sub-stream URL and confirm it is the lower-resolution feed.

Inspect the stream with ffprobe

This reports the codec, dimensions, and frame rate without creating a recording:

ffprobe -v error -rtsp_transport tcp \
  -show_entries stream=codec_name,width,height,r_frame_rate \
  -of default=noprint_wrappers=1 \
  "rtsp://username:password@CAMERA_IP:554/Streaming/Channels/101"

Do not move on until at least the main URL works locally. If it fails, use the RTSP troubleshooting checklist to identify authentication, path, port, and codec failures in that order.

5. Add the camera to LightNVR

  1. Confirm the LightNVR host can route to the camera IP. A cloud instance should use a WireGuard tunnel; do not forward RTSP port 554 from the public internet.
  2. Open the LightNVR interface and select Streams in the main navigation.
  3. Select Add Stream.
  4. Under Basic Settings, enter a short name such as front_door.
  5. Paste the main URL into Stream URL.
  6. Paste the lower-bandwidth URL into Sub Stream URL.
  7. Optionally enter the camera’s web address in Camera Admin URL.
  8. Select Test Connection. Save with Add Stream only after the test succeeds.
Verify both outcomes: open Live to see the camera now, then open Recordings after a recording segment closes to confirm footage is being retained.

6. Tune recording and live view

Once the basic connection is stable, tune one setting at a time:

  • Use H.264 and turn off H.264+/H.265+ while commissioning; smart codecs can produce long or irregular keyframe intervals.
  • Set a regular I-frame interval close to the frame rate—for example, an interval of 15 for a 15 fps stream.
  • Enter 101 as the recording URL and 102 as LightNVR's optional sub-stream URL.
  • Budget using the camera’s configured bitrate, not resolution alone. A 4 Mbps stream transfers about 43 GB per day before retention overhead.
  • After every codec or profile change, rerun Test Connection and check a newly created recording.

7. Troubleshooting

The server returns 401 Unauthorized

  • Verify the account has live-view permission for that channel.
  • Wait for any temporary lockout to expire after repeated password failures.
  • Percent-encode reserved characters in the username or password when they are embedded in a URL.

Channel 1 works but an NVR channel does not

  • Replace the channel portion of 101 with the actual NVR channel, keeping 01 for main or 02 for sub.
  • Confirm the NVR reports that channel online before testing RTSP.
  • Test the channel-specific URL in VLC before adding it to LightNVR.

It works in VLC locally but not from LightNVR Cloud

  • Confirm the WireGuard tunnel shows a recent handshake.
  • Confirm the routed camera subnet contains the camera IP.
  • Test TCP port 554 from the LightNVR side; a successful ping does not prove RTSP is reachable.
  • Open System → System Logs, reproduce the failed connection, and inspect the newest warning or error.

8. Keep the connection secure

  • Use a dedicated camera user with live-view permission instead of the administrator account.
  • Keep the camera on an isolated camera or IoT VLAN when practical.
  • Route RTSP through the LAN or WireGuard; never expose port 554 directly to the public internet.
  • Keep camera firmware current and remove unused accounts and services.
  • Remember that credentials embedded in an RTSP URL are sensitive. Do not paste a real URL into public issues or screenshots.

Vendor reference: Hikvision: RTSP stream URL format. Menu names can move between firmware versions, but the linked vendor documentation is the source of truth for the stream path.