python-dvr icon indicating copy to clipboard operation
python-dvr copied to clipboard

New camera firmware returning different format

Open 420pootang69 opened this issue 5 years ago • 10 comments

So I've had about 5 of these cameras and all have been fine with this library until I got this new one.

Usually on connect the string that is returned is: {u'ExtraChannel': 0, u'ChannelNum': 1, u'Ret': 100, u'DeviceType ': u'IPC', u'SessionID': u'0x0000000C', u'AliveInterval': 20}

Which python says is a "dict"

However on the new camera it's: '{"AliveInterval":21,"ChannelNum":1,"DeviceType ":"IPC","ExtraChannel":0,"Ret":100,"SessionID":"0x00000014"}'

Which python is saying is just a string.

I don't know enough about programming to understand the difference, but I did manage to get this working using json.loads.

So the line: data =self.send(1000,{"EncryptType":"MD5","LoginType":"DVRIP-Web","PassWord":self.sofia_hash(self.password),"UserName":self.user})

Becomes: data = json.loads(self.send(1000,{"EncryptType":"MD5","LoginType":"DVRIP-Web","PassWord":self.sofia_hash(self.password),"UserName":self.user}))

And this fixes the issue. I'm sure there's a better way of doing this, just thought I'd pass this on in case anyone else is stuck.

420pootang69 avatar May 14 '19 18:05 420pootang69

Hmmm... sending settings is no longer working... Stuck now...

420pootang69 avatar May 14 '19 19:05 420pootang69

Dump raw packet. Your things mean it double encoded JSON at auth. You need print at line 88 https://github.com/NeiroNx/python-dvr/blob/master/dvrip.py#L88

NeiroNx avatar May 15 '19 03:05 NeiroNx

Thanks for the detailed reply. It's "data" you want printed here, correct?

420pootang69 avatar May 15 '19 08:05 420pootang69

You need insert at line 88

print(reply)

to view and analyse raw content of package.

NeiroNx avatar May 15 '19 09:05 NeiroNx

{"AliveInterval":21,"ChannelNum":1,"DeviceType":"IPC","ExtraChannel":0,"Ret":100,"SessionID":"0x0000000f"}

Pretty much the same as what I said already!

I've dug into this a bit further and discovered that this camera doesn't actually use a hisilicon chip, it's an "MSC316DM-V02" by Mstar. From what little documentation I can find, the reason it's even responding to these commands as it supports "HK NVR", which allows it to emulate the same command set as the hisilicon cameras.

The DVRs I have here talk with the camera fine, I guess just whatever way they've emulated the Hisilicon/HK NVR commands isn't perfect and it's tripping up the python library.

On another note, this chipset blows the Hilsilicon stuff out of the water. It's an arm7 chip and it can sit merrily encoding 4mp footage at a full 8mbps, no issue. I've used chipsets like the Hisilicon H3516d that choke over 3mbps.

420pootang69 avatar May 18 '19 19:05 420pootang69

{"AliveInterval":21,"ChannelNum":1,"DeviceType":"IPC","ExtraChannel":0,"Ret":100,"SessionID":"0x0000000f"}

Pretty much the same as what I said already!

I've dug into this a bit further and discovered that this camera doesn't actually use a hisilicon chip, it's an "MSC316DM-V02" by Mstar. From what little documentation I can find, the reason it's even responding to these commands as it supports "HK NVR", which allows it to emulate the same command set as the hisilicon cameras.

The DVRs I have here talk with the camera fine, I guess just whatever way they've emulated the Hisilicon/HK NVR commands isn't perfect and it's tripping up the python library.

On another note, this chipset blows the Hilsilicon stuff out of the water. It's an arm7 chip and it can sit merrily encoding 4mp footage at a full 8mbps, no issue. I've used chipsets like the Hisilicon H3516d that choke over 3mbps.

Hi! Did you find any way to send commands with success? I´m stuck at this point.

frascuelillo avatar Oct 22 '19 17:10 frascuelillo

Hi @NeiroNx, do you have any ideas for fixing this?

I really want to change some settings on these cams and this seems to be the only way to do it.

@ frascuelillo have you the same camera set? Thanks.

420pootang69 avatar Nov 24 '19 21:11 420pootang69

Hi @420pootang69 , I think yes, at least the issue is the same. My only advance has been to be able to control the parameters corresponding to VideoColorParam which are the following : info = cam.get_info("AVEnc.VideoColor.[0]")

'VideoColorParam': {'Acutance': 2056, 'Brightness': 100, 'Contrast': 50, 'Gain': 50, 'Hue': 50, 'Saturation': 50, 'Whitebalance': 128}}]

; but I still can't control the exposure.

frascuelillo avatar Nov 29 '19 09:11 frascuelillo

@NeiroNx

I'm looking at using this to grab the alarm flag from the camera to start recording in ZoneMinder. Do you have any idea how I could fix the issue I had with my cameras that the format was slightly off?

420pootang69 avatar Jun 07 '20 21:06 420pootang69

Use Alarm Center function on port 15002 - camera connects to them every time alarm detected and do not need to keep session live.

NeiroNx avatar Jun 08 '20 04:06 NeiroNx