[SOLVED] How to enable multicast on Dahua IPC-HDW3

Malvineous

Getting the hang of it
Jan 7, 2023
35
33
Brisbane, Australia
Hi all,

I have just bought a Dahua DH-IPC-HDW3666EMP-S-AUS-BLK as I have heard Dahua cameras are supposed to be fairly good, however I can't seem to get it to send the video anywhere.

I am using multicast with my existing cameras, which means each camera transmits its video feed to a particular multicast IP (different IP for each camera) immediately and automatically when it is powered on. My other cameras do this, and multiple machines on my network can pick up the multicast stream, so I know my network's multicast routing is working correctly.

However once I enter the multicast IP address in the camera's settings (Options > Network > Multicast) it accepts them without complaint but never starts transmitting any packets. I tried enabling and disabling the substream and all it does is log me out when I apply the changes. Once I log back in again it has kept the changes but there is no multicast traffic leaving the camera. I used SNMP to double-check this, and it shows the multicast counters at zero for all three interfaces:
Code:
IF-MIB::ifName.1 = STRING: lo
IF-MIB::ifName.2 = STRING: eth0
IF-MIB::ifName.3 = STRING: sit0
IF-MIB::ifOutMulticastPkts.1 = Counter32: 0
IF-MIB::ifOutMulticastPkts.2 = Counter32: 0
IF-MIB::ifOutMulticastPkts.3 = Counter32: 0

Doing some Googling tells me that apparently on some cameras you have to change the live view to Multicast, however on my live view I have no options relating to multicast or the protocol, and either way I'm not interested in the browser using multicast, I want the camera to start multicasting packets as soon as it boots up.

Does anyone know how to get the camera to start actually transmitting multicast packets once multicast has been configured?
 
I think I have worked this out. It seems the multicast options shown in the web interface are only for use with RTP, not for true multicast. For true multicast, you have to set the options yourself using the CGI interface.

You can use a web browser for this, or script it with curl or similar.

To view the current multicast settings, go to http://<ip>/cgi-bin/configManager.cgi?action=getConfig&name=Multicast where <ip> is the IP or hostname of the camera. It will return a list of configuration items. The ones that are labelled Multicast.RTP are the ones set via the web interface, but for proper multicast you want the Multicast.TS options.

To set these, use the same URL above, but change everything after the question mark to something like this:
  • ?action=setConfig&Multicast.TS[0].MulticastAddr=239.0.0.1&Multicast.TS[0].Port=1234
  • ?action=setConfig&Multicast.TS[0].Enable=true
And repeat for TS[1] and TS[2] if you want to configure substreams. It looks like you have to set the options and then enable them as two separate calls, it doesn't work if you put all the options in the same URL. Refresh the getConfig URL again to confirm the options have been set.

I configured TS[2] however it doesn't seem to have worked. I get the main stream as per the TS[0] configuration but not the second substream configured with TS[2] (which I put on a different IP).

EDIT: Turns out substream 2 had somehow gotten disabled in the Camera > Encode section. Re-enabling it got multicast working for both streams.
 
Last edited:
Thank you very much for this thread.
It also helped me to change path/name where jpg are saved on ftp with StorageGroup....PicturePathRule and also enable on RecordStoragePoint...AutoSync.

p.s.
any idea what it is: Multicast.DHII as it was enabled by default and I never used this and I did not found something about this on GUI.
table.Multicast.DHII[0].Channel=0
table.Multicast.DHII[0].Enable=true
table.Multicast.DHII[0].LocalAddr=192.168.1.101
table.Multicast.DHII[0].MulticastAddr=239.255.42.42
table.Multicast.DHII[0].Port=36666
table.Multicast.DHII[0].StreamType=Main
table.Multicast.DHII[1].Channel=0
table.Multicast.DHII[1].Enable=false
table.Multicast.DHII[1].LocalAddr=192.168.1.102
table.Multicast.DHII[1].MulticastAddr=239.255.42.42
table.Multicast.DHII[1].Port=36667
table.Multicast.DHII[1].StreamType=Extra1
 
I wondered the same thing about DHII. I have no idea what it could mean. Google only comes up with "Data Highway II" which is an industrial protocol used instead of Ethernet so it can't be that. I know RTP is obviously the Real-Time Protocol, and TS is likely a reference to MPEG-TS (MPEG Transport Stream) as the multicasted data transmitted by the .TS options are wrapped in an MPEG-TS stream. But I've never seen DHII before. I changed quite a few settings on my camera (turning off all services I don't use) however my DHII settings are the same as yours, so it would seem these also aren't made available through the web interface.

The HTTP API document has a reference to DHIIF, however Google doesn't tell me much about that acronym either.

I ended up scripting these options with cURL as it was a bit easier than poking around in the web interface, so if anyone likes scripting or using the command line, here is the cURL command I used:
Code:
# -g is important to pass the square brackets through to the server unchanged
curl -g --digest -u admin:password 'http://192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&Multicast.TS[0].MulticastAddr=239.0.0.1&Multicast.TS[0].Port=5004'

I am using ffmpeg to display the multicasted stream live, and I found that while H.264 worked fine, using H.265 would often fail as ffmpeg misdetected it as H.264. So if anyone else is using ffmpeg to display the multicasted stream live (e.g. you have a Raspberry Pi hooked up to a spare monitor) this is the command I found that worked the best:
Code:
ffmpeg -c:v hevc -i udp:/239.0.0.1:5004 -f xv -
This tells ffmpeg to use the HEVC (H.265) codec instead of trying to autodetect it. "xv" tells it to use the X-Video output device to show the video on the screen instead of saving it to a file. This will only work under Linux, but the ffmpeg docs will tell you which alternatives to use for Windows or Mac if needed.

For completeness, I am using a Linux server as a simple DVR, and I have it set to record the multicast stream to a rotating set of files, so that after one week the oldest files start getting overwritten. If anyone is interested and has a server/NAS that can have ffmpeg installed on it, you can use a command like this to do the same:
Code:
ffmpeg -i udp:/239.0.0.1:5004 -f segment -segment_atclocktime 1 -segment_time 900 -reset_timestamps 1 -strftime 1 "/srv/cctv/cam01-%wT%H%M.mkv" -loglevel fatal
What this does is record the stream to a file named "cam01-2T1315.mkv" where "2" is the day of the week (0=Sunday, 1=Monday, etc.) and 1315 means 1:15pm. The -segment_time 900 means a new file will be started every 900 seconds (15 minutes) so you'll end up with one file for each 15 minute chunk of footage. Because the weekday is included in the filename, it will take seven days for the names to start getting reused and for the old files to get overwritten.

Because ffmpeg can also do video processing, I have used this in the past with MJPEG-only cameras to compress them to H.264, but now with most cameras supporting H.264/5 there's less of a need to do this kind of post-processing.

Although you can do this on any machine that runs ffmpeg (even a Raspberry Pi with enough storage space) I'd recommend against using flash storage for it. The first system I had would save these files onto a Samsung Evo 850 SSD - a fairly good quality product - however after three years of recording footage 24/7 the SSD's write lifetime was reached and it stopped functioning (files became corrupted until eventually the system wouldn't boot). Since then I got some cheap mechanical hard drives and I use those just for the camera footage. Although being mechanical drives they are inherently less reliable and I have already had one fail after only a year, so I guess it's a toss up between guaranteed SSD failure after three years or possible HDD failure without warning but also maybe many years of use too.

At any rate, hopefully someone will find some of this useful one day.
 
  • Like
Reactions: MyDaHua and KenzoS
Changing Multicast.DHII IP and address and also disabling it for safety and camera work as before for 12h ... and hope better/safer.