IpCamera: New IP Camera Binding

That and most of your questions are answered in the docs. Hls does not use the cpu much at all.

1 Like

@matt1

sorry if I am being tiresome :slight_smile:

do you mean this part?

Some older versions of these NVRs require setting a different snapshot URL (snapshotUrl), as well as ffmpegInput. The older ones use the same URLs just with ā€˜ISAPIā€™ removed.

Thing ipcamera:hikvision:West "West Camera"
[
    ipAddress="192.168.0.XX",
    username="username",
    password="password",
    onvifPort=8000, //normally 80 check what it needs
    port=80,
    nvrChannel=4,
    serverPort=54324,
    ffmpegOutput="/var/lib/openhab/ipcamera/West/",
    ffmpegInput="rtsp://192.168.0.XX:554/ISAPI/Streaming/channels/401"
]

if yes then you are saying that i need to set up a Thing for each camera in the NVR right? So the ā€œunitā€ isnt the NVR but rather the camera on the NVR?

Correct you setup a thing for each camera using the same Ip for each one. I agree a bridge thing for an nvr makes sense but that is not in the binding. Also some hikvision nvrā€™s allow each camera to be spoken to directly via different ports for each camera. So there are two ways it can be done depending on what your nvr supports and how it is setup. I donā€™t own one so I can not guide you in that area.

1 Like

@matt1 ok soooo

given my NVR doesnt do Mjpeg, (*h264). & it doesnt do port fw
I need ffmpeg installed, a thing for each camera and I should be able to use the camera oh3 - habpanel json to view cameras on request.

The on request minimizes the impact on processor usage even when hls is always on.

If this is correct I think i got it.
Last question (promise) the binding doesnt actually store stuff right? dont need recording so it wont do naything like that

I have no idea what your nvr offers so it makes it hard to really comment. Does it have RTSP for each camera in h264 format? Does it have snapshot ability?

Hls does not use cpu. It can leave some files behind on your disk as that is how hls works. Other than this it does not store on the disk anything unless you record.

1 Like

it only offers two types of encoding. H264 and H265. so yes I would guess the rtsp is in this encoding and per camera - correct. (i.e. i can access via the isapi link)

thanks! I will work on this plan now to set things up - appreciate your time a lot!

Iā€™m currently running snapshots:

runtimeInfo:
  version: 3.2.0
  buildString: "Build #2529"
locale: en-US
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 11.0.13
  javaVendor: Azul Systems, Inc.
  javaVendorVersion: Zulu11.52+13-CA
  osName: Linux
  osVersion: 5.4.0-89-generic

The INFO line repeats every second or so.

Iā€™m happy to switch back to milestones if needed. Will have to figure that out, but Iā€™m sure it can be done.

I successfully added a Reolink camera.
But having problems adding my doorbell with only a rtsp stream and no username and password.


Enabled tracing and this what I get with no username and password:

2021-10-23 14:05:35.305 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera.mjpeg
2021-10-23 14:05:35.306 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:********-********r********t********s********p********_********t********r********a********n********s********p********o********r********t******** ********t********c********p******** ********-********h********i********d********e********_********b********a********n********n********e********r******** ********-********l********o********g********l********e********v********e********l******** ********w********a********r********n********i********n********g******** ********-********i******** ********r********t********s********p********:********/********/********1********9********2********.********1********6********8********.********0********.********2********5********1********:********5********5********4********/********o********n********v********i********f********1******** ********-********q********:********v******** ********5******** ********-********r******** ********2******** ********-********v********f******** ********s********c********a********l********e********=********6********4********0********:********-********2******** ********-********u********p********d********a********t********e******** ********1******** ********h********t********t********p********:********/********/********1********2********7********.********0********.********0********.********1********:********9********0********2********0********/********i********p********c********a********m********e********r********a********.********j********p********g********

Somehow the FFMPEG parameters are completely garbled. Not sure if this caused by the binding or some other problem in OpenHab

I fixed a bug that does that when there is no user/ password. It is fixed it the jar you can download in this thread.

1 Like

Regarding the error that occurs as a result of trying to ā€œScanā€ for cameras, I have multiple network interfaces connected to my OpenHAB machine. I run OpenHAB on a VM and I have an interface for ā€œnormalā€ LAN traffic and I have an additional interface dedicated to a ā€œCameraā€ LAN.

Could this be causing the errors? It does mention something about ā€œā€¦@Sharableā€¦ā€

Also, I just installed the latest snapshot of your IpCamera binding dated Oct 24, 2021.

There is a problem then and my first guess is that you have not turned on the CGI/API in the cameras setup. Hikvision cameras come with the API disabled and no ONVIF user/pass setup so both of these are needed to be done. See the documentations steps on how to setup Hikvision.

There is an update in the latestest snapshot, can you update to it and retest? The sharable thing is new to me and if it is still occuring, then I will have to look into to see if it can be reproduced hereā€¦ You dont need to scan and find cameras, manually adding them is more than fine and wont be causing the info log problem.

@matt1 thank you for this incredible binding. I have just started working on it. I can confirm it works with the Wainsview line of cameras using ONVIF.

I have done some reading on motion and object detection and must admit I am confused about where to begin. The Wainsview cameras do not seem to have very good detection (or it detects everything that moves).

I would like to be able to detect people, faces if possible, car and license plates if possible. Does the binding do that or do I need a third party application and something like google coral?

I donā€™t know much on object detection yet, but it would be an idea to weigh up the cost of a camera that has it built in. The CPU load to process multiple cameras means that you are best looking at coral or a GPU to offload the processing otherwise your looking at 1 FPS rates at detecting the objects which is OK for sensing objects to use in rules, but if your also wanting to see realtime boxes around the objects you may want a higher rate which the coral is good for. Then there is the issue of network traffic, your best to run multiple cameras and a 3rd party app on a separate switch to keep this traffic away from your openHAB server. For a low number of cameras that is less important to do.

If you want to get started, then there are these ways which I have not tried.

1 Like

Updating to this version and forcing the transport to UDP worked to successfully generate images from the rtsp stream. Thanks for making this binding.
Should the selection of transport al be part of the UI options? (I personally donā€™t have a big problem with adding the argument manually (-rtsp_transport udp))

@matt1 hi Matt,

have you come across a case when adding cameras that it causes issues with other bindings?
I have this case where i have added something like 20 cameras via the RTSP protocol (Hikvision didnt work). they appear on the clickcamera widget. but after finishing and runnign a reboot, the zwave binding has gone offline (and it wont come back online)

almost as if i used up too many system resources - does this make sense?
would it be the habpanel json or the number of rtsp cameras you think that causes it?

(i should add that if i reflash the sd card to prior to adding cameras it is back to normal)
If I remove the ipcamera binding - reboot - it is back to normal. then if I add the binding everything is ok (i guess until next reboot)

Alex

Yes there is a whole thread on this. Milestone 3 fixes this for most people but the latest jar and milestone 4 (due out in 1-2 weeks) should have it resolved.

@alexkarageorgis
This post should have all the info in it that you need.

IpCamera binding - Breaking changes and new features in 3.2 Milestone 3 and newer - Add-ons / Bindings - openHAB Community

1 Like

@JimT, I made rules for my Dahua and Hikvision cameras to change the switch times based on the Astro binding. Let me know if youā€™d like to see how I did it.

Iā€™d love to see your code. I just use Sun elevation (also from astro). Iā€™d like to also do it based on light level, e.g. when itā€™s very overcast / raining during the day, switch it to night profile too. I havenā€™t figured out how to determine the light level. Iā€™d like to do it based on the camera / camera feed itself, and not have to use extra external lux sensors.

Hereā€™s my current code, written in JRuby OpenHAB Rules System

require 'openhab'
require 'net/http'
require 'net/http/digest_auth'

SUN_ELEVATION_THRESHOLD = 5 # Threshold for switching camera profile to day/night

def http_digest_get(url, user:, pass:)
  digest_auth = Net::HTTP::DigestAuth.new

  uri = URI(url)
  uri.user = CGI.escape(user)
  uri.password = CGI.escape(pass)

  h = Net::HTTP.new uri.host, uri.port

  req = Net::HTTP::Get.new uri.request_uri

  res = h.request req
  # res is a 401 response with a WWW-Authenticate header
  auth = digest_auth.auth_header uri, res['www-authenticate'], 'GET'

  # create a new request with the Authorization header
  req = Net::HTTP::Get.new uri.request_uri
  req.add_field 'Authorization', auth

  # re-issue request with Authorization
  h.request req
end

def dahua_set_profile(ip, profile, user, pass)
  profile = { day: '0', night: '1' }[profile]
  http_digest_get("http://#{ip}/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=#{profile}",
                  user: user, pass: pass)
end

rule 'Dahua: Profile switch to day' do
  changed Sun_Elevation
  on_start
  run do |event|
    if Sun_Elevation > SUN_ELEVATION_THRESHOLD && (event.nil? || event.was <= SUN_ELEVATION_THRESHOLD)
      profile = :day
    elsif Sun_Elevation < SUN_ELEVATION_THRESHOLD && (event.nil? || event.was >= SUN_ELEVATION_THRESHOLD)
      profile = :night
    else
      next
    end
    logger.info("DAHUA PROFILE switched to: #{profile}")
    dahua_set_profile(CAMERA_IP['Street'], profile, CAM_USER, CAM_PASS)
  end
end

Thanks Matt,

I am going to have a look at Frigate

hi matt1, I am on milestone3 actually already.
For now I am ok after the unistall/re-install of the binding. Reading up on the link TY and waiting on m4.

the only thing which is strange (besides +10C temp on the RPI) is that the HLS stream isnā€™t consistent on my Amazon Firehd tables/Habpanel. It is better on my mobile phone (samsung note10).

so I have this

but some streams work better/appear and some just stay blank like below. (same setup ofcourse and all from the same NVR)

Is there some way to make the HLS stream faster to load?
Snapshots work ok every 5 seconds (question 2 - do snapshots keep getting ā€œtakenā€ even when the clickable widget isnt the active window?)