IpCamera: New IP Camera Binding

I cant find the cause. So I´m trying to narrow down the reason by changing different settings/stuff.

Yes, but doesnt solve the issue.

For almost any change I make, I clean cache/tmp and reboot. Simply to make sure I´m working on this from a clean setup.

I have checked, doubble checked and tripple checked all settings for typos… I have copy/pasted from your settings in the readme. I have done all I can do to limit typo mistakes as much as possible.
This is my settings right now:

Thing ipcamera:DAHUA:Frontdoor "Frontdoor" @ "Cameras"
[
    IPADDRESS="10.4.28.194",
    USERNAME="admin",
    PASSWORD="password",
    SERVER_PORT=50001,
    ONVIF_PORT=80,
    PORT=80,
    GIF_POSTROLL=6,
    IP_WHITELIST="DISABLE",
    FFMPEG_OUTPUT="/etc/openhab2/html/cams/frontdoor/"
]

Please notice, this is an exact copy from your readme. I just changed the needed stuff.
And then I have changed the ffmpeg_output path, just in case I maybe had some permission issues. (afterwards I have tripple checked for permisions to the path).
I have changed the serverport from my original setup, just in case as well…
I have tried commenting out the Whitelist option, just in a desperate try to see if it changed anything. Thats when I noticed no difference.

Last night, after having tried this setup. I ended up resetting my cam to factory settings. I still end up with the same issue. And as mentioned in previous post, now animated GIF seems to respond with the same issue.

Its certanily not because I want to act disrespectfull, Matt. But I´m getting quite frustrated here, spending alot of time endning up at the very same… It takes a hell of a time to do this, because I clean cache/tmp each time, and waiting for openhab to start up again, sometimes even two restarts, even though this setup is only running with the ipcamera binding.
If this camera has beeing acting like this from the start, I wouldnt have worried this much. But because I know it has worked, things are simply getting very frustrated… I´m sorry if you find me harsh in anyway, thats not my intention at all… I´m just desperate for help/suggestiong as to where I have gone wrong.
Second - My Reolink cam worked fine, which just makes this even more frustrated…

I have two “far out” options left.

  1. Move everything to my Odroid C2 openhab setup (this setup is only running me Velbus devices)… Just to see if it makes any difference.
  2. Unpack me other Dahua camera (same model), connect it and see how it goes.

But I have a feeling I probably end up the same again :weary:

Regarding the camera and numbers of streams…I think there are something wrong, or I simply dont get it. It might be a camera issue though or a Onvif issue.
The camera has 3 streams. one Main, and two sub streams. But when I try to use ONVIF_MEDIA_PROFILE=2, I get an error. And the binding default to use profile=0.
This may not have anything to do with my first issue as that issue happens even when I use ONVIF_MEDIA_PROFILE=0. or profile 1.

That disables the whitelist feature and will allow all access. Removing the line by commenting it out will also allow all access as DISABLE is the default. To get warnings you would need to make it IP_WHITELIST="" or make it equal anything. I have tested it here and it works as intended and does not need a reboot to take effect.

And as mentioned in my previous reply i told you I already gave you the answer in a previous reply to you. Since you don’t read my replies don’t expect for me to give you any more.

Sorry, I thought whitelist was enabled as default and would respond with an error, if not disabled or setup. My bad!

Thats not fair Matt :frowning: 3 days ago you wrote:

I just showed you my latest setting in previous post, and there is no preroll for gif in there, which probably explain why gif animation now gives the same issue as well.

The issue seems to be nailed down on a missing/faulty URL for the RTSP stream.

Did some more testing tonight… And sort of got things to work regarding animated gif and hls streaming, (vlc is streaming the hls m3u8 file right now just fine).
VLC, Onvif Device Manager, Dahua mobile app has no problems stream (live view) the rtsp url. The binding/ffmpeg cant, which seems to be my main issue. I have a teory that ffmpeg may have been updated lately, and its ffmpeg which fails when not using the ffmpeg_input url.

Anyway
There are some sort of problems either with the binding, ffmpeg and/or the camera settings… Even though VLC is streaming the HLS right now and just fine, I get this in the openhab log when the streaming starts:

2020-08-14 00:14:13.727 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [rtsp @ 0x5a3390] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
2020-08-14 00:14:13.784 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x5c2ef0] Non-monotonous DTS in output stream 0:0; previous: 89400, current: 14400; changing to 89401. This may result in incorrect timestamps in the output file.
2020-08-14 00:14:13.807 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x5c2ef0] Non-monotonous DTS in output stream 0:0; previous: 89401, current: 28800; changing to 89402. This may result in incorrect timestamps in the output file.
2020-08-14 00:14:13.817 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x5c2ef0] Non-monotonous DTS in output stream 0:0; previous: 89402, current: 43200; changing to 89403. This may result in incorrect timestamps in the output file.
2020-08-14 00:14:13.835 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x5c2ef0] Non-monotonous DTS in output stream 0:0; previous: 89403, current: 57600; changing to 89404. This may result in incorrect timestamps in the output file.
2020-08-14 00:14:13.853 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x5c2ef0] Non-monotonous DTS in output stream 0:0; previous: 89404, current: 72000; changing to 89405. This may result in incorrect timestamps in the output file.
2020-08-14 00:14:13.858 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x5c2ef0] Cannot use rename on non file protocol, this may lead to races and temporary partial files
2020-08-14 00:14:15.035 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera2.ts
2020-08-14 00:14:15.123 [TRACE] [pcamera.internal.StreamServerHandler] - Connection reset by peer.
2020-08-14 00:14:15.125 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera3.ts
2020-08-14 00:14:15.213 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera4.ts
2020-08-14 00:14:15.301 [TRACE] [pcamera.internal.StreamServerHandler] - Connection reset by peer.
2020-08-14 00:14:16.046 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera.m3u8
2020-08-14 00:14:16.055 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera5.ts
2020-08-14 00:14:17.138 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera.m3u8
2020-08-14 00:14:17.147 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera6.ts
2020-08-14 00:14:17.234 [TRACE] [pcamera.internal.StreamServerHandler] - Connection reset by peer.
2020-08-14 00:14:17.368 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary

Animated Gif has a Debug message as well:

2020-08-14 00:22:59.993 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [swscaler @ 0x1bd96b0] deprecated pixel format used, make sure you did set range correctly

I have tried viewing the gif, but it just got blank on windows 10… I dont know if its a faulty gif or if windows10 simply cant handle this gif…

Since these are Debug messages, and VLC is streaming just fine, I assume I could ignore them… But then, maybe I shouldnt.

This is my settings atm:

Thing ipcamera:DAHUA:Frontdoor "Frontdoor" @ "Cameras"
[
    IPADDRESS="10.4.28.194",
    USERNAME="admin",
    PASSWORD="password",
    SERVER_PORT=50001,
    ONVIF_PORT=80,
    PORT=80,
    GIF_POSTROLL=6,
    IP_WHITELIST="DISABLE",
    FFMPEG_GIF_OUT_ARGUMENTS="-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",
    FFMPEG_HLS_OUT_ARGUMENTS="-strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy -hls_flags delete_segments -hls_time 1 -hls_allow_cache 0 -hls_list_size 3",
    FFMPEG_OUTPUT="/etc/openhab2/html/cams/frontdoor/",
    FFMPEG_INPUT="rtsp://10.4.28.194:554/cam/realmonitor?channel=1&subtype=2"
]

atm this is running on my Rpi4 running openhabian 2.5.7 from SD card…

Can you please show your config on how you got a picture feed on Google hub
i will love to try this THANKS

@Simon_Thorsted
Click on this link, readme just getting updated at the moment.

https://github.com/Skinah/IpCamera#how-to-cast-with-hls

I wanted to try out this binding in OH3, so for anyone interested, you’ll find a .jar here:
https://github.com/ghys/IpCamera/releases/tag/3.0.0-20200814

Note that you still want to download the other .jars (Netty) from @matt1’s link in the OP, this only replaces org.openhab.binding.ipcamera-2.5.X-SNAPSHOT.jar with org.openhab.binding.ipcamera-3.0.0-SNAPSHOT.jar.

1 Like

I you find any issues please report them as I intend to request this binding to get merged as soon as I get the readme updated with some recently added new features. I was going to also test it under Java 12? before merging but if you and others can confirm it works that would save me time… For the first time I cant find bugs, have tested 99% of features recently and can not think of any new features to add, so it is ready to get merged if it is working under OH3 and the newer Java.

1 Like

:+1:
That’s great because there’s a script to convert addons in the openhab-addons would allow the CI to build OH3 versions automatically.
I want to use your binding as a testing for the image & video-related widgets in the new UI, to make sure they’re working and adequate in terms of features.
I only have basic HTTP cameras so I wasn’t able to test many features but I managed to get an Image item updating and also MJPEG & MP4 streams on a separate port, so I’d say it works pretty well.

By the way, just curious, and maybe a silly question as I haven’t dug very deep, but couldn’t the images at least (including MJPEG, not the video streams, I guess) be served by openHAB’s Jetty on the same port? In remote access scenarios for instance where reverse proxying is involved I figure it would cause problems, server-relative URLs would solve many of them (and eventually authorization could be enforced too).

Not sure if Openhab’s Jetty could do the following? It certainly could do basic serving but I suspect these is where it may lack?..

  1. Detect when files are requested so I can start generating things on demand. Then detect when the tcp channel is closed to then stop generating and free back up the CPU. Tight integration.
  2. I need to generate CORS headers to allow things to be cast to google/nest devices. The Jetty way fails to work as it wont create the CORS, yet the custom Netty works as I can send what is needed to make it work. I lack the knowledge to know if Jetty can be configured to do this. I know NGINX can do it but what I have implemented is seamless and works.
  3. I use the servers to do what some people call WEBHOOKS? I may be using the wrong term. Some cameras and ONVIF need to use GET requests to trigger events. Once again having tight integration makes things easy. I would not know where to start to get Jetty to inform what GET requests are made back to my binding.

I could keep listing reasons but at the end of the day I am not a programmer, I am fully self taught and I lack the knowledge and time to make calls. Interested if they could be done and I would not be surprised either way.

Good to hear its working at least to some extent under the newer Java, I look forward to checking out the cool new features in Openhab 3 soon. Thanks so much for all the work you (and many others) are putting into it.

2 Likes

After upgrading openHAB to 2.5.8 #200 snapshot and the binding to version “ipcamera-2020-08-05.zip” I am seeing the exact same behaviour: ipcamera.gif is not working anymore.
Did you solve the problem? Thx.

No…
There seem to be an issue between the Onvif url and the url beeing parsed on to ffmpeg. From the log, the url looks just fine when the binding scans the camera (Onvif), but ffmpeg return an 404 error (not found).
I have given up spending any more time on this, since it looks like I have to deal with it myself.

A possible workaround.
If you manually set the url for ffmpeg_input to the stream, it will probably work. I managed to get animated gif and hls streaming working just fine this way.

2 Likes

THAT was a nice one! Got my animated gifs working again with your workaround. Thx a lot.

1 Like

Did you use the same URL that was auto detected or use a different one? What brand of camera? I have 3 different brands of cameras here and they are all auto detecting and working great so this is confusing since nothing from memory changed in an area that would make a difference recently. This is why a new thread is needed so we can look at what versions you had and went to, other changes made like java version or ffmpeg version got changed.
I guess it may be the overriding is not the direct fix, it may be that your openhab server has not updated the UTC time and by entering in an override you restarted the binding after the time on the openhab server had been synced with the internet. Some cameras will refuse to answer as it is part of the onvif spec that the date and time must be within 5 seconds. This is to block hackers from reusing recorded traffic so if the Date and time on a ARM based board is many years in the past from just having rebooted this could be the cause. I use a real time clock device on my odroid.

The logs in trace mode will tell you the cameras and openhabs UTC date and time but currently I have not written code to flag an automated warning.

Unfortunately I won’t be able to answer a lot of your questions because I did something which should normally not be done: I upgraded openHAB and the operating system (Debian 10 on X64) almost at the same time.
After upgrading openHAB and looking at clean logs I upgraded the os …

A different one.

Dahua IPC-HFW1320S-W

I upgraded openHAB from 2.5.4 to 2.5.8 #200 snapshot. I have no idea about any software versions for the operating system, sorry. I did the usual apt upgrade.

I am using ntp to always have the correct system time.

If I find the time next week I will try to use the auto detected url again to see if that works again.
Thanks for this great binding, it was the first time I had a little glitch with it :slight_smile:

have you ever tried to bring the cam to openhab? Have you had a chance to get RTSP streams into openhab?

New build uploaded (no changes worth mentioning) and the binding is now waiting to be reviewed and merged:

1 Like

hi everyone, i am currently trying to integrate my ezviz vc 206 ip camera into the binding. With Motioneyeos it already works quite well. however, it doesn’t seem to work completely in openHAB yet. the configuration seems to be ok so far. unfortunately i don’t see a stream yet, or get data from the camera. is there a way to debug or a way to find the error?

Thing ipcamera:HIKVISION:Wohnzimmerkamera "Kamera im Wohnzimmer" @ "Wohnzimmer"
[
    IPADDRESS="192.168.1.140",
    USERNAME="admin",
    PASSWORD="******",
    SERVER_PORT=54323,
    ONVIF_PORT=8000,
    STREAM_URL_OVERRIDE="ffmpeg",
    SNAPSHOT_URL_OVERRIDE="ffmpeg",
    FFMPEG_OUTPUT="/mnt/ipcamera/wohnzimmer/", 
    FFMPEG_INPUT="rtsp://192.168.1.140/h264_stream",
    IP_WHITELIST="DISABLE"
]

Log (endless repetitions):

08-23 16:41:32.647 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.1.140, re-starting it now
2020-08-23 16:41:41.697 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Binding has no snapshot url. Will now use your CPU and FFmpeg which must be installed to create snapshots from RTSP.
2020-08-23 16:41:41.719 [WARN ] [io.netty.channel.nio.NioEventLoop   ] - Selector.select() returned prematurely 512 times in a row; rebuilding Selector io.netty.channel.nio.SelectedSelectionKeySetSelector@7ba068aa.
2020-08-23 16:41:42.697 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.1.140, re-starting it now

Apologies if this has already been covered somewhere else. I looked but did not see it.

I have a Hikvision camera with audio. I know how to use the binding to get audio triggers - that works fine. But what I was wondering is if there is an audio URL that I can tap into with something such as VLC to listen to what is going on at the camera live. If I get an audio alarm but no motion alarm, I would like to trigger an audio record, or be able to navigate to a live audio stream since there is nothing showing on the video feed (since there is no video motion). Anyone have experience with this?

Camera is a HikVision DS-2CD2543G0-IWS

See readme for more info:

HLS gives you live streams with audio if you change default settings. I use this to cast my baby monitor camera to my nest hub and my chromecast on my tv and I get audio.

MP4 recordings can be made With binding and contain audio.