IpCamera: New IP Camera Binding

Glad you like it. You can also use the control to stop HLS if it has auto started and you don’t wish to wait for it to timeout.

That depends on your goal, if it is for lower HLS startup delay and less lag behind realtime then yes. 1 second segments require 1 second iframes and then you can lower the number of segments as well. But it increases the amount of data.

Don’t forget you can always cast a snapshot or gif if you need an instant picture when a doorbell is pressed.

@m4rk
Soz for the mistake my bad. If it is in the readme or somewhere I need to edit please let me know…

You do have each camera with its own SERVER_PORT and nothing else on those ports? try other ports or a reboot, that is not normal and is going to be an issue.

As for the image not always updating correctly, try the poll time slightly lower to give the binding more time to place the jpg into ram before the refresh line requests it. 9500ms for example.

The incorrect time was here >>>

Server ports are all different. I changed them anyway.

Hi Matt,

I went back to my old method. The ipcamera.jpg method is proving to be too unstable. The refresh doesn’t always retrun with an image and now I get this everytime I view the sitemap…
Tried reboot, clear cache but didn’t help.

2020-01-26 16:46:22.183 [WARN ] [pcamera.internal.StreamServerHandler] - Exception caught from stream server:{}

java.lang.NullPointerException: null

	at io.netty.buffer.Unpooled.copiedBuffer(Unpooled.java:360) ~[bundleFile:4.1.42.Final]

	at org.openhab.binding.ipcamera.internal.StreamServerHandler.sendSnapshotImage(StreamServerHandler.java:201) ~[?:?]

	at org.openhab.binding.ipcamera.internal.StreamServerHandler.channelRead(StreamServerHandler.java:116) ~[?:?]

New build 2020-01-27 has these changes:

  • Change to HLS feature. HLS streams smoother on some browsers now.
  • Fixed every second ipcamera.jpg request in some browsers was failing.
  • Polling can now go past 1 per minute and is not limited now.

@m4rk
In addition to the above fixes, I tested using the image channel through an item and it worked great when the poll time matched the refresh. I then decided to try this line with the camera still updating more often. I believe this may be a bug in Openhab, as it refreshes way more than every 2 minutes and is very erratic. The refresh is handled by the Openhab core and if it occurs more often than it should, this is something that should be reported at Openhabs GitHub issue tracker. I made a change in the binding to allow for higher poll times, so 15 minutes between poll times should be possible in next build unless it is a foscam as they need the poll time lower for the alarm checking.

Image item=BabyCamImage refresh=120000

Hi, i have a small problem: my image.mjpeg stream stops working after some time. When i make a browser refresh, the stream is running again…

I can see some abnormal messages in the trace-log after the time the stream stops… Hope it is helpful:

2020-01-27 12:37:19.796 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:37
Code=AudioAnomaly;action=Stop;index=0

:
2020-01-27 12:37:20.809 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:41
Code=VideoMotionInfo;action=State;index=0

:

This lines with :–myboundary only are visible when the stream has stopped. When the stream is running, there are other messages visible, but not like the two above.

I don’t believe they are connected as they look like the results from the alarm stream for Dahua cameras. Maybe they are connected and it is a bug in the camera sending the alarm data out the wrong stream, in which case upgrade your cameras firmware and contact their support. It is possible that some cameras will shutdown the stream if left running for X amount of time. This could be handle in one of two ways…

  1. Use the refresh option added to your video element, from memory I tried this and it worked, but you get a interruption in the picture each time it refreshes.
  2. The binding could be made to auto detect and restart the stream without any interruptions other than the picture appears to freeze whilst the stream is re-opened. Unless your watching the time tick over or there is motion you probably would not notice a 1 second or less freeze occur.

Thanks, would be grade if this could be included in the binding.

I have a cheap dahua china cam, i can´t upgrade the firmware… I will try to remove the audio alarm, because this is useless for me, my frontdoor is some meters near the street and i get false alarms every time a car or a person drives/walks by.

I can´t use refresh in my sitemap with video. I get errors, also in the manual it is no refres option described.


Now i disabled both alarms (audio/motion) and will wait some time, if the stream stops again…

EDIT:
Stream is also stopping after some time…

EDIT2:
MJPEG-Stream from the binding is stopping after some time - but the snapshots-mjpeg (full-hd) stream from the binding seems to be more stable…
My dahua cam is providing a mjpeg stream (at lower resolution - about 700x400) and the cam is serving this without the need of user/password.

I may have been using webview and refresh when testing but the issue is the stream will stay stop until the next refresh comes
Around and if you refresh often you get more glitches. Not optimal like proposed solution.

Yes snapshots.mjpeg is created by the binding and does not come from the camera so interested to hear how it performs long term.

Also don’t rule out the browser being the cause of a stream closing. Do some google searches.

I´m still struggling with my Reolink RCL 410 on my test setup (Rpi4), trying to archive getting the HLS streaming and animated GIF support… But I´m getting alot closer now.

However, I seem to have a permission problem after installing FFMPEG… The binding is not allowed to write the gif file to the output folder I have specified in the things file. I installed FFMPEG according to the readme file, and then created a /tmpfs/camera1/ folder, which I have defined as the output folder in the things file.
Where did I go wrong, and how to fix it? (I am useless regarding Linux and permissions… I simply dont get it :frowning: ).

My cam stops working every few hours - it has something to do with the gif creation. I made some loginfo into my rules and i can see, that sometimes the binding should create a gif and i get this with email - but after that i only get a standing picture in my snapshots.mjpeg stream from the time the gif-creation ended.
–> also the switch “gif creation” still is ON

Today morning at 6 a.m. a cat walked by my frontdoor - i got a gif. And now at 7.30 a.m. i can still only see a not movimg picture with the snapshots.mjpeg-link from the time, the gif was created from - no more new pics. Even browser refresh will not bring back the stream. Also cam-reboot didn´ßt help, only openhab-server reboot was usefull.

I changed the gif creation from standard values to preroll=3 and postroll=20. Will do further testings with standard values, if this caused the problem.

I removed my second cam (cheap china cam) from my things file completely and i disabled audio/motion alarm on my dahua. I also removed the image channel of my dahua from the items-file. But this was no help.

Openhab Service restart didn´t help… I got many of this error messages, when openhab is starting and even after some minutes of running, still no new picture from snapshots.mjpeg

2020-01-29 08:12:02.469 [WARN ] [pcamera.internal.StreamServerHandler] - Exception caught from stream server:{}

java.lang.NullPointerException: null

	at io.netty.buffer.Unpooled.copiedBuffer(Unpooled.java:360) ~[bundleFile:4.1.42.Final]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.sendMjpegFrame(IpCameraHandler.java:1063) ~[?:?]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.setupSnapshotStreaming(IpCameraHandler.java:1001) ~[?:?]

	at org.openhab.binding.ipcamera.internal.StreamServerHandler.channelRead(StreamServerHandler.java:119) ~[?:?]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]

	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [bundleFile:4.1.42.Final]

	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:328) [bundleFile:4.1.42.Final]

	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302) [bundleFile:4.1.42.Final]

	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]

	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) [bundleFile:4.1.42.Final]

	at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044) [bundleFile:4.1.42.Final]

	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [bundleFile:4.1.42.Final]

	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [bundleFile:4.1.42.Final]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]

After that i did an Openhab Server reboot and now it is working again…

Did some more testing:

With gif_preroll set to a value greater then 0 ( in my case 3 seconds) i get this error-messages

2020-01-29 14:48:00.635 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !!!! Camera has closed a channel 	URL: Cause reported is: {}

io.netty.util.concurrent.BlockingOperationException: DefaultChannelPromise@51a8dbcf(incomplete)

	at io.netty.util.concurrent.DefaultPromise.checkDeadLock(DefaultPromise.java:461) ~[bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPromise.checkDeadLock(DefaultChannelPromise.java:159) ~[bundleFile:4.1.42.Final]

	at io.netty.util.concurrent.DefaultPromise.awaitUninterruptibly(DefaultPromise.java:267) ~[bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:137) ~[bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:30) ~[bundleFile:4.1.42.Final]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.sendHttpRequest(IpCameraHandler.java:557) ~[?:?]

	at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.processAuth(MyNettyAuthHandler.java:177) ~[?:?]

	at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.channelRead(MyNettyAuthHandler.java:227) ~[?:?]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]

	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [bundleFile:4.1.42.Final]

	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:328) [bundleFile:4.1.42.Final]

	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302) [bundleFile:4.1.42.Final]

	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]

	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) [bundleFile:4.1.42.Final]

	at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044) [bundleFile:4.1.42.Final]

	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [bundleFile:4.1.42.Final]

	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [bundleFile:4.1.42.Final]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]

2020-01-29 14:48:00.641 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler 		URL:/cgi-bin/snapshot.cgi?channel=1

2020-01-29 14:48:00.635 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !!!! Camera has closed a channel 	URL: Cause reported is: {}

io.netty.util.concurrent.BlockingOperationException: DefaultChannelPromise@62309285(incomplete)

	at io.netty.util.concurrent.DefaultPromise.checkDeadLock(DefaultPromise.java:461) ~[bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPromise.checkDeadLock(DefaultChannelPromise.java:159) ~[bundleFile:4.1.42.Final]

	at io.netty.util.concurrent.DefaultPromise.awaitUninterruptibly(DefaultPromise.java:267) ~[bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:137) ~[bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:30) ~[bundleFile:4.1.42.Final]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.sendHttpRequest(IpCameraHandler.java:557) ~[?:?]

	at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.processAuth(MyNettyAuthHandler.java:177) ~[?:?]

	at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.channelRead(MyNettyAuthHandler.java:227) ~[?:?]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]

	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [bundleFile:4.1.42.Final]

	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:328) [bundleFile:4.1.42.Final]

	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302) [bundleFile:4.1.42.Final]

	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]

	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]

	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]

	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552) [bundleFile:4.1.42.Final]

	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) [bundleFile:4.1.42.Final]

	at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044) [bundleFile:4.1.42.Final]

	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [bundleFile:4.1.42.Final]

	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [bundleFile:4.1.42.Final]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
2020-01-29 14:48:18.643 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !?! Channel that was found idle could not be located in our tracking. !?!

2020-01-29 14:48:18.643 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !?! Channel that was found idle could not be located in our tracking. !?!

2020-01-29 14:48:18.643 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler 		URL:

2020-01-29 14:48:18.644 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler 		URL:
2020-01-29 14:50:28.095 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - There are 13 channels being tracked, cleaning out old channels now to try and reduce this to 12 or below.

2020-01-29 14:50:28.095 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just found a connection with wrong open state.

2020-01-29 14:50:28.095 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just found a connection with wrong open state.

2020-01-29 14:50:28.095 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just found a connection with wrong open state.

2020-01-29 14:50:28.096 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just found a connection with wrong open state.

2020-01-29 14:50:28.096 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just found a connection with wrong open state.

2020-01-29 14:50:28.096 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just found a connection with wrong open state.

2020-01-29 14:50:28.096 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cleaning the channels has just found a connection with wrong open state.

When i change gif_preroll to 0 it works very good…

I´m not sure how to get past my permission issue… I have tried changing the ffmpeg output folder. But that doesnt change anything…
This is the error I get every time I try to create a animated Gif.

2020-01-29 21:33:28.199 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - FileNotFoundException {}
java.io.FileNotFoundException: /etc/openhab2/html/camera1/snapshot5.jpg (Permission denied)
	at java.io.FileOutputStream.open0(Native Method) ~[?:1.8.0_222]
	at java.io.FileOutputStream.open(FileOutputStream.java:270) ~[?:1.8.0_222]
	at java.io.FileOutputStream.<init>(FileOutputStream.java:213) ~[?:1.8.0_222]
	at java.io.FileOutputStream.<init>(FileOutputStream.java:162) ~[?:1.8.0_222]
	at org.openhab.binding.ipcamera.handler.IpCameraHandler.storeSnapshots(IpCameraHandler.java:1082) [bundleFile:?]
	at org.openhab.binding.ipcamera.handler.IpCameraHandler.setupFfmpegFormat(IpCameraHandler.java:1144) [bundleFile:?]
	at org.openhab.binding.ipcamera.handler.IpCameraHandler$3.run(IpCameraHandler.java:1666) [bundleFile:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:1.8.0_222]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_222]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:1.8.0_222]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

This is my thing file:

Thing ipcamera:HTTPONLY:Reolink "Frontdoor Camera" @ "Cameras"
[
    IPADDRESS="10.4.28.202",
    USERNAME="username",
    PASSWORD="password",
    PORT=80,
    POLL_CAMERA_MS=1000,
    SERVER_PORT=54321,
    UPDATE_IMAGE=false,
    GIF_PREROLL=1,
    GIF_POSTROLL=6,
    IP_WHITELIST="DISABLE",
//    SNAPSHOT_URL_OVERRIDE="http://192.168.1.181/capture",
//    STREAM_URL_OVERRIDE="http://192.168.1.181:81/stream",
    FFMPEG_OUTPUT="/etc/openhab2/html/camera1/",
    FFMPEG_INPUT="rtsp://username:password@10.4.28.202:554//h264Preview_01_main"
]

Same problem here with my dahua. After few days, Intrusion was detected, GIF creation recieve ON but never return to OFF. I have to restart openhab (not the camera).

I think that is the best option for now till the cause is found. It would be handy if you could capture the moment it happens with TRACE log output to see what was happening.
I use gif with a preroll all the time and no issues.

Please, does anybody make use of the SV3C Camera more over?
What kind of camera type can identify this model? Perheaps only httponly is supported?
Which kind of test can I do with it to verify?
Sorry, very newby with this kind of integration

Hi there!
I bought a DAHUA XVR1B08 NVR (8 channels) recently and I am now trying to integrate everything into openhab. It shows up online in paper UI, snapshots.mjpeg works as expected (although in extremely low resolution - it looks like it’s using the low res 2nd stream of the camera, and I can’t find any options to increase it - does anyone know if it is possible?).

But, mainly I am having issues getting the HLS stream to work… I have Openhabian running on my Raspberry Pi (with an external drive). I installed ffmpeg as instructed in the readme and the path to it is set correctly in FFMPEG_LOCATION - /usr/bin/ffmpeg. I set the FFMPEG_OUTPUT to /home/openhabian/camera/ (I am running my Pi on an SSD anyway, so I don’t see the need for a RAM drive - nor is there much RAM to spare). But whenever I try to access the HLS stream from the browser I get this in the openhab log:

2020-01-31 23:04:32.062 [INFO ] [pcamera.internal.StreamServerHandler] - IpCameras file server could not find the requested file. This may happen if ffmpeg is still creating the file.

I tried setting the RTSP URL manually to:
rtsp://xxxx:pass@192.168.1.30/cam/realmonitor?channel=1&subtype=0&authbasic=XXXXXXX
which opens nicely in VLC. It didn’t change anything. The file specified in the FFMPEG_OUTPUT doesn’t get created.

Any ideas - what am I missing?

New Build 2020-02-01 has these changes:

  • New Netty version 4.1.45 Final used which included a lot of bug fixes that were known in the previously used 4.1.42 Final. Remove older jar files and best to clean cache and tmp when moving to this version. Then restart openhab multiple times to re-create the cache.
  • GIF now updates more smoothly at 2x speed and does not miss snapshots. Speed can be changed via arguments.
  • Cameras that use ffmpeg for snapshots will now see an improvement.
  • autofps.mjpeg stream can stay open for longer poll times up to 3000ms if a browser supports it.
  • jpg can be cast again.

@roli
snapshots: see the cameras settings, not done in the binding but in the camera.
HLS: enable debug log output and read what the issue is. readme has how to do this.

@Brignoud
Use ONVIF first then httponly if you have any issues.

1 Like

@matt1
For snapshots I am aware that it’s most likely a camera thing. But I am asking if anyone has a similar NVR and knows anything.
Also… Camera seems to have the sub stream set to MJPG whenever I connect to it with the binding:


But… if I want to set it manually… there is no MJPG option at all:
Screenshot 2020-02-01 at 15.45.36
How can it be set to MJPG if there is no MJPG option at all? Does the API do something weird here?

As for HLS… You were right. I already did that once, but missed the ffmpeg log. Here it is:

2020-02-01 15:30:45.428 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:/usr/bin/ffmpeg  -i rtsp://xxxxx:yyyyyyy@192.168.1.30/cam/realmonitor?channel=1&subtype=0&authbasic=xxxxxxxxxxx -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy -hls_flags delete_segments -segment_list_flags live -flags -global_header /home/openhabian/camera/ipcamera.m3u8

2020-02-01 15:30:45.825 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - ffmpeg version 3.2.14-1~deb9u1+rpt1 Copyright (c) 2000-2019 the FFmpeg developers

2020-02-01 15:30:45.828 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516

2020-02-01 15:30:45.831 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   configuration: --prefix=/usr --extra-version='1~deb9u1+rpt1' --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-omx-rpi --enable-mmal --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --arch=armhf --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared

2020-02-01 15:30:45.837 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   libavutil      55. 34.101 / 55. 34.101

2020-02-01 15:30:45.839 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   libavcodec     57. 64.101 / 57. 64.101

2020-02-01 15:30:45.841 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   libavformat    57. 56.101 / 57. 56.101

2020-02-01 15:30:45.843 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   libavdevice    57.  1.100 / 57.  1.100

2020-02-01 15:30:45.844 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   libavfilter     6. 65.100 /  6. 65.100

2020-02-01 15:30:45.846 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   libavresample   3.  1.  0 /  3.  1.  0

2020-02-01 15:30:45.848 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   libswscale      4.  2.100 /  4.  2.100

2020-02-01 15:30:45.850 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   libswresample   2.  3.100 /  2.  3.100

2020-02-01 15:30:45.853 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   libpostproc    54.  1.100 / 54.  1.100

2020-02-01 15:30:48.556 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Input #0, rtsp, from 'rtsp://xxxxx:yyyyyyyy@192.168.1.30/cam/realmonitor?channel=1&subtype=0&authbasic=xxxxxxxxxxxx':

2020-02-01 15:30:48.560 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   Metadata:

2020-02-01 15:30:48.562 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     title           : Media Server

2020-02-01 15:30:48.565 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   Duration: N/A, start: 0.100000, bitrate: N/A

2020-02-01 15:30:48.570 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 960x576, 100 tbr, 90k tbn, 180k tbc

2020-02-01 15:30:48.573 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Input #1, lavfi, from 'aevalsrc=0':

2020-02-01 15:30:48.576 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   Duration: N/A, start: 0.000000, bitrate: 2822 kb/s

2020-02-01 15:30:48.579 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Stream #1:0: Audio: pcm_f64le, 44100 Hz, mono, dbl, 2822 kb/s

2020-02-01 15:30:48.581 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x242b410] Opening '/home/openhabian/camera/ipcamera0.ts' for writing

2020-02-01 15:30:48.584 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Could not write header for output file #0 (incorrect codec parameters ?): Permission deniedStream mapping:

2020-02-01 15:30:48.587 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   Stream #0:0 -> #0:0 (copy)

2020-02-01 15:30:48.589 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -   Stream #1:0 -> #0:1 (pcm_f64le (native) -> aac (native))

2020-02-01 15:30:48.591 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Last message repeated 1 times

2020-02-01 15:30:48.597 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [aac @ 0x22903b0] Qavg: nan

Am I correct in thinking that this is due to audio codec mapping? Though this thing annoys me, because I have audio disabled in the camera stream settings (I don’t even have audio).

I have the same issue.
But I think its related to the permission issues I cant seem to get rid of.