IpCamera: New IP Camera Binding

Hi, since upgrading to OH3.2 from 3.1 I am struggling to get my Reolink 511WA to work. It was working pretty well under 3.1 (the below issue would come up very, very rarely), but with OH3.2 the camera is not working most of the time.

I have set up the camera with an Onvif profile, port 8000. As I said, that was all working well enough with OH3.1. I have linked only a few channels to items, mainly the ones relating to alarms / motion detection, none related to getting images, video, etc.

Ever since upgrading to OH3.2 I am getting the below warning every few hours, and then usually four times within a minute:

2022-01-07 16:48:18.726 [WARN ] [amera.internal.onvif.OnvifConnection] - Binding could not determin the cameras current PTZ location. Not all cameras respond to GetStatus requests.

Also, most of the time now the items stop functioning, ie motion alarms do not arrive in OH anymore, although there have been episodes where they have been working again for a couple of hours. Could not make out what was different, though.

There were no obvious configuration errors in the camera thing, so I tried deleting the thing and then re-adding it (the scan function did not find the camera, so I had to add manually as an Onvif camera). That did not fix the issue, though, the above warning popped up afterwards again.

Looking at the thing / items a bit closer, I see that all the alarm items, including the ones that used to work previously (eg LastMotionType and CellMotionAlarm) remain NULL, despite alarms being registered by the camera. On the other hand, just for testing I activated the Url items, and they do receive proper values.

Not sure whether that is relevant, but I also have the camera connected to Synology Surveillance Station, and there all alarms are registered well and recordings are created.

I am a bit at a loss now and would very much appreciate any ideas or pointers on how to get this going againā€¦

Can you open your own new thread and place a summary of your system in it and also some DEBUG and TRACE level logs from when the camera first connects (use pause and unpause button in the thing) and also when the alarm first stop working. The docs have a section titled what to do if you need help, please read that first.

Sure, will do, thanks.
Hereā€™s the post:

Hi,

I have a very similar issue. In OH 3.1 everything works as expected then I upgradet to 3.2 because of an other Binding witch wasnĀ“t working in OH3.1.
But now the Camera Binding isnĀ“t working anymore.

When I power the camera OFF and ON the stream URL (http://openhab:8080/ipcamera//ipcamera.mjpeg) is not working.
When I have a fresh installation of the Binding the url is working till I power off the camera.

Do you have a fix for that?

Hi community,
Iā€™m looking for a security camera most compatible with OH.
On first post I can read the most featured cam are the ONVIF with API.
Now when I read the tested cam list I can see 2 kind of cameras:
API cameras
Onvif Cameras.
Is right to say that the API cameras include the onvif and are the most complete?

Any suggestion is accepted. I donā€™t have any cam, so I want to buy a unique brand and I need a pan/tilt cam and some static cam.
The pan/tilt can be PoE but I prefere WiFi (better wifi6), the static cameras should be wifi.
All the cameras should be API and onvif.
Thanks to all

Yes all cameras in the first post of this thread that have an API are onvif as well as I have not bothered to add any apis from brands that are not. The exception is foscam which not all models get support added to them for some reason. If your wanting PTZ then look at Dahua and Amcrest.

@Joko my reply is the same as I posted in reply to the person above just a few posts before yours.

Hi,

This plugin seems to work well. But I only open the channel with the live feed or call the JPG url very infrequently, however, the ffmpeg seems to runs all the time and seems to be heavy on CPU;


I current have only added 1 of 4 cameras.

Is it possible to set it so the processing of the feed only happens on demand and stop when not being used?

Thanks.

The binding does, the issue your having may be that the widget/browser that is showing the camera is keeping it running after you navigate away. Try entering the URL directly in a browser and starting and stopping.

I have to press the refresh button after I leave the page that shows the camera for it to stop.

@matt1 - as soon as I start openhab service (after stopping it) I get one ffmpeg running at 1-2% cpu. If I open the habpanal app on my phone and open the feed I get another ffmpeg running at 10% cpu. I assume this is the video. if i move to different pages on the app, the process keeps running. I need to end the android app before the 10% cpu task stops.

The task thatā€™s 1-2% I assume is JPG capture. I only have 2 channels set. The live feed and the JPG.

But I havenā€™t even viewed the JPG. its ffmpeg task seems to start as soon as server starts. Thatā€™s right?

UID: ipcamera:generic:ac0f3d4faa
label: RTSP/HTTP IP Camera
thingTypeUID: ipcamera:generic
configuration:
  mjpegOptions: -q:v 5 -r 2 -vf scale=640:-2 -update 1
  ipAddress: 172.17.90.102
  updateImageWhen: "0"
  mjpegUrl: ffmpeg
  gifPreroll: 0
  ffmpegLocation: /usr/bin/ffmpeg
  ipWhitelist: DISABLE
  mp4OutOptions: -c:v copy -c:a copy
  pollTime: 1000
  port: 554
  snapshotUrl: ffmpeg
  snapshotOptions: -an -vsync vfr -q:v 2 -update 1
  ffmpegInput: rtsp://172.17.90.102/user=admin_password=_channel=1_stream=1
  gifOutOptions: -r 2 -filter_complex
    scale=-2:360:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse
  hlsOutOptions: -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy
    -hls_flags delete_segments -hls_time 2 -hls_list_size 4

That is correct the jpg extracting from rtsp runs non stop and is tweaked for low CPU so 1-2% sounds right. I highly recommend upgrading to any onvif camera or any camera that has snapshot ability. Any camera that has a snapshot ability will be far better as it wonā€™t open a stream to extract jpg, and the jpg is only on demand.

I have done minimal testing on what happens if the steam is interrupted so there may be issues running it long term.

The issue is it takes around 2-4 seconds to start a rtsp stream with ffmpeg so if it was on demand the snapshot would be from probably 3 seconds after the time you asked for the snapshot. With a fast CPU it may be faster then for an ARM based system.

hi, question: Server Port option is now unavailable? i cannot find that line and was needed to publish my ipcamera on the web from openhabā€¦any idea?

thanks

Hey matt1,

thank you very much. After I enabled the TRACE loging I found out, that my onvif port was wrong.
I dindĀ“t changed anything so the default value of 80 was set.
Maybe the settings in the camera changed now it is 8000 and it is working.

Cheers Joko

Hi all
Iā€™ve installed a Tp-link Tapo c200 using onvif generic and it works, i can view stream with widget ā€œClickablePTZCameraā€ and i can use PTZ movement.
Now iā€™d like to use also the ā€œprivacy modeā€ that the cam has.
I googled a lot and i found a way with a pyton library ā€œpytapoā€ that send the request using

{ā€œmethodā€: ā€œsetā€, ā€œlens_maskā€: {ā€œlens_mask_infoā€: {ā€œenabledā€: ā€œonā€}}}

is there a way to add this feature to your binding?

Thanks

Correct it is now on the same server that openhab uses which is 8080 by default. See search this forum for a post explaining the breaking change.

After some calls from e.g. oh-image-card the ffmpeg stream does not run anymore. If I kill the ffmpeg process via the console, then everything works again. Is there a way to restart the process somehow by rule, or does anyone of you also have this effect?

- component: oh-image-card
    config:
      title: Livebild Kamera HaustĆ¼r
      url: http://10.0.0.87:8080/ipcamera/haustuer/snapshots.mjpeg
UID: ipcamera:generic:haustuer
label: IP Kamera HaustĆ¼r
thingTypeUID: ipcamera:generic
configuration:
  mjpegOptions: -q:v 5 -r 2 -vf scale=640:-2 -update 1
  ipAddress: 10.0.0.60
  mjpegUrl: ffmpeg
  updateImageWhen: "0"
  gifPreroll: 0
  ffmpegLocation: /usr/bin/ffmpeg
  ffmpegOutput: /etc/openhab/html/camera/
  ipWhitelist: DISABLE
  mp4OutOptions: -c:v copy -c:a copy
  pollTime: 1000
  port: 80
  snapshotUrl: ffmpeg
  snapshotOptions: -an -vsync vfr -q:v 2 -update 1
  ffmpegInput: rtsp://10.0.0.60/ch0_1.h264
  gifOutOptions: -r 2 -filter_complex
    scale=-2:360:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse
  hlsOutOptions: -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy
    -hls_flags delete_segments -hls_time 2 -hls_list_size 4

Everything is running on a Raspberry 4 with openhabian.

IMHO You should not need a rule, the binding should just restart itself so this should be considered a feature request.

Since I donā€™t use any cameras that need a RTSP feed for the snapshot, I have never tested and developed that area of the binding beyond making it work. Being robust against certain things like the camera rebooting or simply closing the stream as the camera does not like to stay running past a certain length of time, is something that should be looked at. I just donā€™t have this very high on ā€œMYā€ to do list, perhaps someone else will step up to do itā€¦

In the next milestone build due out soon, there are some new advances in the binding for keeping RTSP to mjpeg conversions running, so I recently made that change which should allow ipcamera.mjpeg to keep working very robust for you at the cost of more CPU powerā€¦ There is also a request to improve the RTSP to alarm features to stop them closing if the camera wants to reboot, so this is just another area to be added to the ā€˜to improveā€™ list. Even if it was added, your using a camera in a way that wont get tested very often, so there are advantages to changing to a camera that is used by more people so the bugs get found/fixed faster.

Personally my opinion is that you should not do this on your openHAB server as it takes away bandwidth from having a stream running non stop when cameras that donā€™t cost much more can simply supply a snapshot and use a lot less bandwidth and CPU from your server. See the very first post of this thread for a comparison between camera types/brands and features.

You can also setup another software package like blue iris, zoneminder or shinobi and get them to create the snapshot from the stream. This can be on another PI which will take the load off your openHAB server and if placed on a different network switch with the cameras, this can take the traffic off your openhab network which will yield benefits. Depending on the number of cameras and network devices that you have this may be a recommended way, or overkill.

So your options are (pick one):

  1. Change your camera to one that has a snapshot url.
  2. Use a external program to create the snapshots from the rtsp feed that never closes.
  3. Change to using the newer binding and use the ipcamera.mjpeg feed instead of the feeds that are built from snapshots.
  4. Raise an issue on github and wait for the change to be made.

Hi

I am sure the problem is on my side, but since the update to 3.2 my stream doesnĀ“t work anymore.

UID: ipcamera:onvif:Kamera_Haustuere
label: Kamera_Haustuere
thingTypeUID: ipcamera:onvif
configuration:
  mjpegOptions: -q:v 5 -r 2 -vf scale=640:-2 -update 1
  ipAddress: 192.168.1.230
  mjpegUrl: http://192.168.1.143:8006/ipcamera.mjpeg
  updateImageWhen: "0"
  gifPreroll: 0
  onvifPort: 80
  ffmpegLocation: /usr/bin/ffmpeg
  ipWhitelist: DISABLE
  mp4OutOptions: -c:v copy -c:a copy
  pollTime: 1000
  password: D1dpd1mfhah
  port: 80
  snapshotOptions: -an -vsync vfr -q:v 2 -update 1
  ptzContinuous: false
  onvifMediaProfile: 0
  ffmpegInput: rtsp://xxxxx:xxxxxxxx@xxxxxxxx/user=xxxxx_password=xxxxxxxx_channel=1_stream=0.sdp
  gifOutOptions: -r 2 -filter_complex
    scale=-2:360:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse
  hlsOutOptions: -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy
    -hls_flags delete_segments -hls_time 2 -hls_list_size 4
  username: admin

If I type in the url in the browser I get : ERR_CONNECTION_REFUSED

OK 3.2
RPI 4
HiKam A7 2nd Generation

Maybe you have a tip.

BR
Daniel

Search the forum or read the release notes to learn about the breaking change and what to do. There is a thread I created to explain it and will be easy to find if you search 3.2 ipcamera breaking change.

I think Foscam have moved to a ā€˜preferredā€™ cloud subscription model. You cannot configure the new C2 (feels like a childā€™s toy) without a Mac or WinOS (plugin required). So, if your Android phone cannot complete the config, youā€™re basically stuffed. If you check on REOLinkā€™s site, they give a big list of ā€œno browser accessā€ cameras. I think only the high end RLC models have access.

@matt1, Thanks for the help with my cams a few weeks ago. Having used this plugin a while now I donā€™t think the screen capture from non onvif cams really works by using the ffmpeg stream and keeping it open always (even at low cpu). I think it just dies after a period and become unusable. Since itā€™s not an often used thing, could it just open the cam, process a frame, then close it? I know this would be a slower process and give a slower access time on the frame, but it would probably be stable, which seems a better requirement. Current one is not stable enough to actually be of use at all.

I donā€™t really have the option to replace my whole cctv setup to onvif, would be a huge job and itā€™s so close as is, streaming when required works well, just need a more stable way to take the odd fixed frame.

This possible?