Tue, 24 Apr 2018 UTC

# Dahua NVR DAV files

Dahua are a white-label OEM who are apparently responsible for many common models of IP camera and Network Video Recorder (NVR) systems. Files exported from such a system have a .dav extension and a header identifying the manufacturer:

$ hexdump -Cn 1024 NVR_ch1_main_20180416.dav
00000000  44 41 48 55 41 22 05 00  25 5c 21 49 da 60 21 49  |DAHUA"..%\!I.`!I|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400

These files seem to be some proprietary format containing multiple H.264 streams concatenated with framing and other data data. If the streams are from different cameras, they can also be different resolutions.

ffmpeg can’t mux these straight into MP4 - at least, not in a way that plays in VLC. MKV works though.

$ ffmpeg -i NVR_ch1_main_20180416.dav -c:v copy 20180416.mkv

The down-side of this is that it doesn’t play in many other players.

Transcoding will lose a little quality and result in slightly distorted video when the input resolution changes mid-stream, but produce a file that’s playable even by Windows Media Player.

$ ffmpeg -i NVR_ch1_main_20180416.dav -c:v libx264 -preset slow -crf 18 -vf scale=1024:-1 20180416.mp4
tags : cli ffmpeg video