Hikvision setup

My cameras have built in mic, any way to get the audio stream as well?

1 Like

HASS and most browsers only have native support for displaying mjpeg streams. H.264 gets trickier in universal support.

No audio support as far as i’m aware on any of the camera platforms. There may be something in FFMpeg if you want to look through those docs.

Thanks, will do.

I’m getting the following since I added the camera as you suggested, any ideas?

17-04-27 01:10:03 WARNING (Thread-3) [requests.packages.urllib3.connectionpool] Failed to parse headers (url=http://192.168.200.54:80/Streaming/Channels/2/preview): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ‘’
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py”, line 398, in _make_request
assert_header_parsing(httplib_response.msg)
File “/srv/homeassistant/lib/python3.4/site-packages/requests/packages/urllib3/util/response.py”, line 66, in assert_header_parsing
raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
requests.packages.urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ‘’
17-04-27 01:10:13 WARNING (Thread-8) [requests.packages.urllib3.connectionpool] Failed to parse headers (url=http://192.168.200.54:80/Streaming/Channels/2/preview): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ‘’
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py”, line 398, in _make_request
assert_header_parsing(httplib_response.msg)
File “/srv/homeassistant/lib/python3.4/site-packages/requests/packages/urllib3/util/response.py”, line 66, in assert_header_parsing
raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
requests.packages.urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ‘’
17-04-27 01:10:23 WARNING (Thread-9) [requests.packages.urllib3.connectionpool] Failed to parse headers (url=http://192.168.200.54:80/Streaming/Channels/2/preview): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ‘’
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py”, line 398, in _make_request
assert_header_parsing(httplib_response.msg)
File “/srv/homeassistant/lib/python3.4/site-packages/requests/packages/urllib3/util/response.py”, line 66, in assert_header_parsing
raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
requests.packages.urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ‘’

That’s a known bug in the urllib3 library. You can suppress the log messages (they are harmless) by adding this line under your logger/logs section in your configuration.yaml.

requests.packages.urllib3: critical

I got my camera working with the above config - works a treat :smiley:

Is it possible to manually trigger recording? I am using Hikvision cameras with Synology Surveillance Station (SS). Neat thing about SS is that it can automatically pre-record a few seconds (can be configured) before the actual trigger.

There is a post here that triggers manual recording, but it will be nice to get something integrated in the pyhik library.

@arsaboo Unfortunately, there are no hikvision API commands to trigger recording so there isn’t anything I can add to pyHik. I’ve seen some people have success with a workaround involving hardware alarm triggers which can be flipped via the api. If your cameras have support for that option it may be worth looking into.

I just do everything within the cameras (options are actually fairly robust) and point the recording location to mounted images on my unraid server so everything is stored in one place.

Is 480p the maximum resolution for MJPEG?
Could I set to 720p at least?

I think it’s camera specific, but I’ve only ever seen 480p as an option. The mjpeg format isn’t as efficient as something like rtsp so I don’t know if it can handle higher resolutions well.

Oh yeah, substream only has 480 maximum resolution.
Could I get live streaming on HASS if I use rtsp instead?

I believe you can use RTSP streams with the ffmpeg component.

Other than getting the rtsp link from my hikvision cameras
How do I properly add it to HASS with ffmpeg component? Is there a guide I can refer to?
Nevermind, I think I found it here

https://community.home-assistant.io/t/rtsp-support/2306/22

Better question is, would I get smooth 720p or 1080p streaming on HASS?

I have the Hikvision DS-2CD2332-I and couldn’t come close to live streaming 1080p with Hassbian on Raspberry Pi 3. So I am using the secondary stream set to 640x480 and H.264 with a low framerate:

I initialise the ffmpeg component in configuration.yaml:

ffmpeg:
  ffmpeg_bin: /usr/bin/ffmpeg

And finally have the following in my cameras.yaml:

- platform: ffmpeg
  name: Camera Name
  input: rtsp://username:password@cam_ip:554/Streaming/Channels/2
  extra_arguments: -vf scale=640:360

For some unknown reason the my Hikvision substream does not provide a 16:9 resolution option so I need to have ffmpeg rescale the image aspect ratio so that it doesn’t look “tall and thin”. Let me know if you find a better solution.

2 Likes

Thanks Pete, it’s probably gonna consume too much resource for the HD streaming
Are you able to get the hikvision motion detection working with HASS?
Or do you just rely on the email/notification alert from the ivms app?

Also, is 2 fps enough? Is there a certain limit (like 15-20fps) for streaming on HASS before it gets bogged down?

I use BlueIris for Security Camera recording. BlueIris gets the Hikvision’s main stream at 1080p and records to NAS at 15 fps which is way more than needed. It has a pretty full set of motion detection options but it’s still a bit hit and miss for me as my cameras are outside and trees/shadows/rain play havoc with that. So I am looking to combine door/PIR/weather information from HA to improve the reliability of detection. In essence, I am using HA as a data source and to generate notifications rather than replace the main video security system. So 1-2 fps on the HA stream is fine for initial observation as I can always go into BlueIris to review in higher definition if needed.

1 Like

Hey,
I’m using line crossing sensor to send a notification via pushbullet which works well, is there a simple way to add a snapshot to the notification as well?

EDIT: Here’s a not so simple solution.

I don’t know if the pushbullet platform supports images. If it does I would simply pass along the externally accessible snapshot url to the camera. You could either do this through the hass proxy or the camera itself.

How did you get the camera to send notifications thru home assistant?

I’m using Pushbullet with Line Crossing.