← All How-To Guides
Camera setup

How to Connect Dahua Cameras to LightNVR

Use Dahua's realmonitor endpoint to select the correct camera channel and stream, then connect it to LightNVR over the local network or a private tunnel.

8 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. Dahua cameras and recorders commonly share this endpoint, including many OEM models, but menu names and available extra streams vary by firmware. Use the device's configured RTSP port if it is not 554.

2. Prepare the Dahua camera

  1. Reserve the camera IP: Find the camera in ConfigTool or your router's DHCP leases, then reserve its address so LightNVR always reaches the same host.
  2. Check network ports: In the camera web interface, open Setting, Network, then Connection or Port and confirm RTSP is enabled. The default is 554.
  3. Check the Encode profiles: Under Camera or Video, open Encode and confirm Main Stream and Sub Stream 1 are enabled with the resolutions and codecs you intend to use.
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/cam/realmonitor?channel=1&subtype=0
Lower-bandwidth live streamrtsp://username:password@CAMERA_IP:554/cam/realmonitor?channel=1&subtype=1

Dahua channel numbering starts at 1. subtype=0 is the main stream, subtype=1 is extra stream 1, and subtype=2 may be available when the device exposes a second extra stream.

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/cam/realmonitor?channel=1&subtype=0"

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:

  • Start with the main stream in H.264 and a fixed bitrate to remove smart-codec variability from the first test.
  • Use extra stream 1 as LightNVR's sub stream for a lighter multi-camera live view.
  • Keep the I-frame interval close to the configured frame rate for predictable recording segments and seeking.
  • 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 URL opens the wrong camera on a recorder

  • Change channel=1 to the recorder channel that owns the camera.
  • Confirm channel numbering in the recorder UI; it starts at 1, not 0.
  • Keep subtype=0 for main or subtype=1 for the first extra stream.

Login succeeds in the browser but RTSP is unauthorized

  • Confirm the user has monitor/live-view permission for the requested channel.
  • Try a dedicated camera account with a URL-safe username, then percent-encode any reserved password characters.
  • Check the account lockout status after repeated failed tests.

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: Dahua: RTSP via VLC reference. Menu names can move between firmware versions, but the linked vendor documentation is the source of truth for the stream path.