IpCamera: New IP Camera Binding

this is how it looks in my case:

UID: ipcamera:onvif:Reolink
label: Reolink
thingTypeUID: ipcamera:onvif
configuration:
  mjpegOptions: -q:v 5 -r 2 -vf scale=640:-2 -update 1
  ipAddress: 192.168.1.234
  updateImageWhen: "0"
  onvifPort: 8000
  gifPreroll: 0
  ffmpegLocation: /usr/bin/ffmpeg
  ipWhitelist: DISABLE
  mp4OutOptions: -c:v copy -c:a copy
  pollTime: 1000
  password: password
  port: 80
  snapshotOptions: -an -vsync vfr -q:v 2 -update 1
  ptzContinuous: false
  onvifMediaProfile: 1
  username: username
  hlsOutOptions: -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy
    -hls_flags delete_segments -hls_time 2 -hls_list_size 4
  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

atm I just want to show the livestream. I don´t think its a binding issue, as my TP cam streams 24/7

BR

You do not need to include the user:pasword@ the binding will handle it without this so that the password is only in one place and hidden in a password field. It works both ways thou, I just think it makes it easier to change your password and then only update it in 1 place.

Further to this minor point I have these as well…

  1. You have onvifMediaProfile listed twice.
  2. onvifMediaProfile is 0 but you are wanting to use substream 1 so you can make this onvifMediaProfile = 1 and then rely on full auto discovery of the url by the binding and not over ride the ONVIF system. IE you can then leave out the ffmpegInput and it should be auto found and supplied by ONVIF.

Since you have a working setup, can you tell me (to help the other people) if the auto discovery and setup is not working correctly? Why have you needed to provide the url manually? If there is an issue, it needs to be looked at as to why, so it can be fixed, but so far no one is reporting there is a problem, nor providing the logs to show what happens.

Do you have the sub stream enabled in the cameras setup? Most cameras come with substreams disabled, does 0 the mainstream work before you try moving to a value of 1? I do not know Reolink cameras at all so I do not know the default settings and capabilities.

@Daniel_OH
Really it is pointless asking people to guess at what is wrong. The correct and fast way is to read the very first section of how to get help and follow it. I need logs that show exactly what is going on AND it placed in its own separate thread.

IP Camera - Bindings | openHAB

@matt1
Thank you for the hint, I removed the duplicate onvifMediaProfile.
The reason for using the ffmpegInput was to have a known good input to view substream 1

I tried to use the discovery but it did not work. I assumed this was due to using not supported cameras or similar. I still have 4 other Reolink cameras which should support ONVIF. When scanning I get the error below.

2022-02-19 13:59:49.364 [ERROR] [nternal.DiscoveryServiceRegistryImpl] - Cannot trigger scan for thing types ‘[ipcamera:hikvision, ipcamera:onvif, ipcamera:foscam, ipcamera:doorbird, ipcamera:generic, ipcamera:dahua, ipcamera:instar, ipcamera:amcrest]’ on ‘IpCameraDiscoveryService’!
io.netty.channel.ChannelPipelineException: org.openhab.binding.ipcamera.internal.onvif.OnvifDiscovery$2 is not a @Sharable handler, so can’t be added or removed multiple times.
at io.netty.channel.DefaultChannelPipeline.checkMultiplicity(DefaultChannelPipeline.java:600) ~[?:?]
at io.netty.channel.DefaultChannelPipeline.addLast(DefaultChannelPipeline.java:202) ~[?:?]
at io.netty.channel.DefaultChannelPipeline.addLast(DefaultChannelPipeline.java:381) ~[?:?]
at io.netty.channel.DefaultChannelPipeline.addLast(DefaultChannelPipeline.java:370) ~[?:?]
at io.netty.bootstrap.Bootstrap.init(Bootstrap.java:262) ~[?:?]
at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:311) ~[?:?]
at io.netty.bootstrap.AbstractBootstrap.doBind(AbstractBootstrap.java:272) ~[?:?]
at io.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:268) ~[?:?]
at org.openhab.binding.ipcamera.internal.onvif.OnvifDiscovery.discoverCameras(OnvifDiscovery.java:220) ~[?:?]
at org.openhab.binding.ipcamera.internal.IpCameraDiscoveryService.startScan(IpCameraDiscoveryService.java:70) ~[?:?]
at org.openhab.core.config.discovery.AbstractDiscoveryService.startScan(AbstractDiscoveryService.java:195) ~[?:?]
at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:377) ~[?:?]
at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.startScans(DiscoveryServiceRegistryImpl.java:362) ~[?:?]
at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:211) ~[?:?]
at org.openhab.core.io.rest.core.internal.discovery.DiscoveryResource.scan(DiscoveryResource.java:105) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) ~[bundleFile:3.4.5]
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) ~[bundleFile:3.4.5]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) ~[bundleFile:3.4.5]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) ~[bundleFile:3.4.5]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) ~[bundleFile:3.4.5]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) ~[bundleFile:3.4.5]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) ~[bundleFile:3.4.5]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) ~[bundleFile:3.4.5]
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:265) ~[bundleFile:3.4.5]
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) ~[bundleFile:3.4.5]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) ~[bundleFile:3.4.5]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) ~[bundleFile:3.4.5]
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:225) ~[bundleFile:3.4.5]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:298) ~[bundleFile:3.4.5]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:217) ~[bundleFile:3.4.5]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) ~[bundleFile:3.1.0]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:273) ~[bundleFile:3.4.5]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550) ~[bundleFile:9.4.43.v20210629]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) ~[bundleFile:?]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:602) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1434) ~[bundleFile:9.4.43.v20210629]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:294) ~[bundleFile:?]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1349) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[bundleFile:9.4.43.v20210629]
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:82) ~[bundleFile:?]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.Server.handle(Server.java:516) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:386) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) [bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) [bundleFile:9.4.43.v20210629]
at java.lang.Thread.run(Thread.java:829) [?:?]

You could rule this out by…

  1. remove all cameras from the network, ie unplug them.
  2. restart openHAB to ensure it is a clean restart with no errors already having occurred.
  3. Scan for cameras and if it only happens when a camera is on the network, but does not if there are none then it would need to be looked at from a camera causing the binding to crash.

I have looked at the coding the error gives me some hints so thanks for posting it. I suspect it may be caused by a bug handling multiple network cards. My system only has 1 network card so I never see that error. Its possible that if your using on a system with wifi and wired network cards it may be hitting a bug that I can not reproduce with only 1 network. In this case it would be happening with every raspberry pi owner and I would be stunned why no one has reported it yet.

If you could help narrow down the cause that would be great.

Also separately the discovery I was really referring to was what happens when a camera connects that is already added as an ONVIF thing. It talks to the camera and asks for the date and time and any URLs that the camera has and more. This handshake is what I am keen to see as you should not have to give any URLS to the binding, if the camera is truly ONVIF compatible. If there is a bug in this area it would be great to squash it.

I am using a docker container on amd64. The OH container runs network_mode: host. The host has a macvlan defined named pubhost_net as there is multiple docker containers on the same host having their own IP. Shall I provide a trace of such a discovery?
Unplugging all cameras is a quite time consuming action I would like to avoid BUT I am willing to do it to help to improve the binding.

br-ea659a0dad55: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
ether 02:42:f6:db:df:81 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:fff:fedc:42a8 prefixlen 64 scopeid 0x20
ether 02:42:0f:dc:42:a8 txqueuelen 0 (Ethernet)
RX packets 212373 bytes 30659497 (29.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 410667 bytes 24794209 (23.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.123.10 netmask 255.255.255.0 broadcast 192.168.123.255
inet6 fd00::42a8:f0ff:feae:abdb prefixlen 64 scopeid 0x0
inet6 fe80::42a8:f0ff:feae:abdb prefixlen 64 scopeid 0x20
ether 40:a8:f0:ae:ab:db txqueuelen 1000 (Ethernet)
RX packets 96244329 bytes 110035697774 (102.4 GiB)
RX errors 0 dropped 1475021 overruns 0 frame 0
TX packets 52579638 bytes 30178784527 (28.1 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf7c00000-f7c20000

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 10346373 bytes 14879659160 (13.8 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10346373 bytes 14879659160 (13.8 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

pubhost_net: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.123.221 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::e439:31ff:fe61:3a37 prefixlen 64 scopeid 0x20
inet6 fd00::e439:31ff:fe61:3a37 prefixlen 64 scopeid 0x0
ether e6:39:31:61:3a:37 txqueuelen 1000 (Ethernet)
RX packets 6634935 bytes 18135683325 (16.8 GiB)
RX errors 0 dropped 48757 overruns 0 frame 0
TX packets 624172 bytes 42993737 (41.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

I searched the forum for a part of the error and found this thread:

IpCamera Discovery error - Setup, Configuration and Use / Installation - openHAB Community

1 user also with Docker, another I will have to assume does not use Docker as they use openhabian.
I have a USB network card laying around so I can try adding it to mine and see if I can reproduce the error. It may be a rights issue accessing the network card. This is certainly not my strong area but I suspect it has nothing to do with the cameras and more to do with accessing the NIC network cards.

I’m sorry that I’m not clear in my wording here. Currently it seems to work again without me changing anything. the only thing I can think of as a difference to the TP Link camera is that the TP Link is connected directly to the switch, while the Reolink is supplied via powerline. and therefore perhaps a little less reliable.

BR

After upgrading from OH3.1 to OH3.2 there are some changes with the binding…

3.1: Request a snapshot with the URL http://192.168.xxx.xxx:54321/ipcamera.jpg <= was working fine (incl. recorded .gif)
3.2: Request a snapshot with the URL http://openhabIP:8080/ipcamera/{cameraUID}/ipcamera.jpg <= not working for myself anymore.

Thing ipcamera:generic:esp32cam
[
ipAddress=“192.168.100.56”,
gifPreroll=1,
pollTime=2000,
ipWhitelist=“DISABLE”,
snapshotUrl=“http://192.168.100.56/capture”,
mjpegUrl=“http://192.168.100.56/stream”,
ffmpegInputOptions="-f mjpeg",
ffmpegOutput="/tmp/openhabcams/",
ffmpegInput=“http://192.168.100.56/stream
]

.gif exists of cause:
grafik

Any Idea’s?

There was a braking change. Read rel ase notes and search this forum.

Hi @matt1 , I’ve read through several threads, your git commits, the docu etc.

I cannot finde any reason or issue, just read and followed the 3.2 addon docu carefully…
Nevertheless, it’s not working for me, that’s why I’m asking here…

EDIT:
Seems that I found the issue…
UUID is not “ipcamera:generic:esp32cam” it’s just “esp32cam”…

thx.

how to get rid off errors in the logs for Video URL ? I have Dahua cam which has 3 streams and for 3rd one I configured in cam as mjpg which want to show in a sitemap:
`

Video url=“http://xxx:xxx@xxx.xxx.xxx.xxx/cgi-bin/mjpg/video.cgi?channel=1&subtype=2” encoding=“mjpeg”

`
errors when opening or refreshing a sitemap:

2022-03-03 12:06:23.065 [ERROR] [java.net.CookieManager ] - Invalid cookie for http://xxx.xxx.xxx.xxx/cgi-bin/mjpg/video.cgi?channel=1&subtype=2: secure; HttpOnly
2022-03-03 12:06:23.065 [ERROR] [java.net.CookieManager ] - Invalid cookie for http://xxx.xxx.xxx.xxx/cgi-bin/mjpg/video.cgi?channel=1&subtype=2: secure; HttpOnly

Also strange that on PC I can see video and on android phone with Openhab App no way… Still on OH 2.5, plan to upgrade to 3.2 later this year.

Your using the camera directly and not the binding, so I am confused why your posting in this thread? Read the bindings documentation and then open your own new thread.

actualy I’am using the binding for other camera and for dahua I want to show mjpeg stream directly from it :wink:

Hi Matt

Yesterday my livestream of the Reolink stopped again - time on the camera was 23:23:07.

These are the logs around this period.

I think it has nothing to do with your binding or openhab (As the TP Link works most of the time), but maybe someone had the same issue and can tell me what wo change on the camera.
openhab_log_20220304.txt (50.9 KB)

Thank you

Your log shows the FIFO is full, so read the problem and the fix to try here:

Https video stream not possible - potentially problem with self signed certificate? - Add-ons / UIs - openHAB Community

Hi @matt1
Would if be possible to get a switch to reboot hikvision thru api /System/reboot?

If I am correct, channels are for when there is a STATE like a light globe is ON or OFF, and rebooting does not have a state, as it is something that you trigger to occur. It is only temporary and you are not able to know the difference between rebooting and the camera being offline. I believe what would be considered the correct way to do it, is implement it as an ACTION which would require you to setup a rule to trigger the action when the switch is moved.

This then makes it almost just as easy to create a script and call the script when the switch is moved with a rule. To be clear I don’t like this answer I am giving and wish it was simple to create a switch for an action that takes zero arguments. It should be simple, to just add a camera and get advanced actions available in the main UI without the need to research and spend 20+ minutes setting it up when it should be available to add when your creating some equipment in the model.

Sadly after a quick github search it appears that actions still are not fully supported by mainUI/core

[automation] Binding actions cannot be configured by UIs · Issue #1745 · openhab/openhab-core (github.com)

This is something which is best raised as a request in github, especially as I am busy on another binding at the moment and a post in this long thread is only going to get lost.

1 Like

Hi

Since I always had problems with the Livestream, I have now test an own Rasperry PI in use for the IP Camera Binding. The only binding installed is the IP Camera binding.
Nevertheless, the stream stops after some time.
However, the binding shows me both cameras as online.
I have a copy from the live logging attached as well as the logfile from this afternoon. According to the camera image, the stream stopped at 17:51. Im am running on openhab 3.3 snapshot

Logfile_Live.txt (55.9 KB)

Logfile during end of stream (OneDrive)

When I disable and then enable the binding, it works again.

Cameras
TP Link Tapo and Reolink

BR
Daniel

Have you tried to connect the cameras with lan cable?
I have problems with reolink WLAN camera but with cable it works great.

Hi Sebastian

both are connected via LAN.

I thought maybe its due to the powerline, but for test purposes I connected both cameras directly to the switch. At the time of the failure, both were directly connected to the switch

BR