DJX Systems — AI automation studio in Williamsburg, Virginia
Menu
Dahua / IC Realtime NVR skill
TECHNICAL GUIDE

Download Dahua NVR footage as MP4 by time range

A practical workflow for exporting recorded Dahua-family DVR/NVR clips with HTTP CGI, RTSP playback, and ffmpeg. It applies to many Dahua OEM recorders, including IC Realtime, newer Lorex, Amcrest, Honeywell Performance, and similar systems.

The user request sounds simple: "export channels 1, 3, and 4 from 12:02:10 to 12:02:30 as MP4s." The recorder side is messier. Dahua-family systems expose useful HTTP CGI and RTSP interfaces, but firmware differences, stream formats, timestamp encoding, and OEM quirks make reliable MP4 export more than a single URL.

Manual workflow

  1. Confirm CGI and RTSP access from the export machine. The machine running the export workflow needs HTTP or HTTPS access to the recorder for CGI calls and RTSP access for the fallback path. Use a recorder account with playback/search permission, not a shared admin account if you can avoid it.
  2. Map friendly camera names to Dahua channel numbers. Most failed exports start with the wrong channel. Write down the camera name, Dahua channel index, main/sub stream choice, and whether the camera is connected directly to the NVR PoE ports or added over the LAN.
  3. Search recordings with mediaFileFind.cgi before downloading. Use the recorder search API to find the segment that covers your requested window. Search a padded range when possible so firmware boundary quirks do not cause you to miss the actual clip.
  4. Try the fast CGI download path first. When loadfile.cgi returns a complete segment, it is usually faster than RTSP playback. Inspect the response, because some firmware returns DHAV, some returns a raw H.264/H.265 bitstream, and some returns an error payload that only looks like a download.
  5. Convert or remux into a normal MP4. Dahua-family recorders may export DHAV or raw video instead of a browser-friendly MP4. Remux DHAV when possible, rebuild timing for raw streams, and apply faststart so the clip opens cleanly for non-technical users.
  6. Fall back to RTSP playback and verify the result. RTSP playback is slower, but it is the safety net when CGI export is incomplete or unsupported. Always verify duration, codec, frame rate, and whether the clip covers the requested time window.

Dahua CGI endpoints to know

The usual manual route starts by searching with mediaFileFind.cgi, then downloading the matching recording with loadfile.cgi. Exact parameters vary by model and firmware, so treat this as the workflow shape rather than a universal copy-paste command.

# 1) Search recorded files for the requested channel and time window
/cgi-bin/mediaFileFind.cgi?action=factory.create
/cgi-bin/mediaFileFind.cgi?action=findFile&object=...&condition.Channel=1&condition.StartTime=YYYY-MM-DD HH:MM:SS&condition.EndTime=YYYY-MM-DD HH:MM:SS
/cgi-bin/mediaFileFind.cgi?action=findNextFile&object=...&count=100

# 2) Download a returned file path or segment
/cgi-bin/loadfile.cgi?action=startLoad&channel=1&startTime=YYYY-MM-DD HH:MM:SS&endTime=YYYY-MM-DD HH:MM:SS

If the download path returns a complete video segment, convert it to a standard MP4 and trim locally. If it returns a short or unusable file, use RTSP playback as a slower but often more compatible fallback.

Example RTSP fallback shape

ffmpeg -rtsp_transport tcp \
  -i "rtsp://USER:PASSWORD@192.168.1.50:554/cam/playback?channel=1&starttime=YYYY_MM_DD_HH_MM_SS&endtime=YYYY_MM_DD_HH_MM_SS" \
  -map 0:v -c copy channel-1-clip.mp4

Dahua RTSP playback URL shapes vary across firmware and OEM brands. Validate the path on the actual recorder, and be careful with URL escaping when passwords contain symbols.

Failure modes to plan for

When automation is worth it

One manual export is manageable. Repeated exports for incidents, security reviews, sports clips, or multi-site support become a process problem: somebody has to remember channels, time formats, fallback behavior, conversion commands, and verification checks every time.

That is why I built the Dahua / IC Realtime NVR AI Agent skill. It wraps search, download, conversion, RTSP fallback, clipping, credential storage, and verification so a SKILL.md-compatible AI agent can handle plain-English footage requests and return a checked MP4.

Get in touch