IpCamera: New IP Camera Binding

New version works great, now i can see a mjpeg video from my cheap china cam which only provides rtsp-stream.

Anybody already has a working setup with sending a gif in an email, when there is movement?

Hi @ all
running this binding quite a while now, works perfect internally, but I am not able to setup mjpg stream at all…just no success.
The HLS stream is working, but I wonder if somebody is willing to give me his / her things configuration for foscam resp. the http thing?
Thanks for your effort

@Kim_Andersen
I got the new google metadata working. Just add and ask Google to ‘sync devices’. Info being added to readme at the moment.

String FrontDoorCamHlsUrl "Front Door" { channel="ipcamera:DAHUA:FrontDoor:hlsUrl", ga="Camera" [ protocols="hls" ] }

@halloween
See the readme for a pushover example should be easy to adapt it to email. I recommend using pushover as you can tell it to keep X number of messages as a history and it auto deletes them for you, plus the sound is different on your phone to an email.

@alkaline
See the readme file under the heading on what special steps are needed for Foscam, you need to use a url to enable mjpeg streams. Also not all Foscam models support mjpeg, recently they released some cheaper models that clearly state the feature is not in the firmware so check their website and contact their support. There is also a new feature only added in the last few days called ‘snapshots.mjpeg’ see the readme for more info as that gives higher resolution anyway and I prefer it over higher FPS and lower quality streams.

Perfect Matt…
I´ll still need to figure how to setup the hls streaming… But as soon as I get there, I´ll give it a shot… Would love to see it streamed to my Nest Hub on request.

I updated to the new version today.
But i have a problem with the “auto-update” of the snapshot.

Although i configured following in paperUI: image
It keeps updating (Same for all other settings)

Item definitions:

Image   cam_hof_snap                    "Kamera Hof Bild"                                               { channel="ipcamera:ONVIF:e5e853ce:image" }
Switch  cam_hof_update                  "Kamera Hof Update"                                             { channel="ipcamera:ONVIF:e5e853ce:updateImageNow", expire="2s,OFF" }

Log:

2020-01-20 13:30:27.336 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 732216 bytes to raw type (image/jpeg): 731392 bytes
2020-01-20 13:30:29.083 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 731392 bytes to raw type (image/jpeg): 731768 bytes
2020-01-20 13:30:31.214 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 731768 bytes to raw type (image/jpeg): 731696 bytes
2020-01-20 13:30:31.528 [ome.event.ItemCommandEvent] - Item 'cam_hof_update' received command ON
2020-01-20 13:30:31.541 [nt.ItemStatePredictedEvent] - cam_hof_update predicted to become ON
2020-01-20 13:30:31.551 [vent.ItemStateChangedEvent] - cam_hof_update changed from OFF to ON
2020-01-20 13:30:32.450 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 731696 bytes to raw type (image/jpeg): 732120 bytes
2020-01-20 13:30:33.172 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 732120 bytes to raw type (image/jpeg): 731568 bytes
2020-01-20 13:30:34.119 [vent.ItemStateChangedEvent] - cam_hof_update changed from ON to OFF
2020-01-20 13:30:35.213 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 731568 bytes to raw type (image/jpeg): 731944 bytes
2020-01-20 13:30:37.196 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 731944 bytes to raw type (image/jpeg): 732776 bytes
2020-01-20 13:30:39.283 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 732776 bytes to raw type (image/jpeg): 732872 bytes
2020-01-20 13:30:41.229 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 732872 bytes to raw type (image/jpeg): 732744 bytes
2020-01-20 13:30:43.281 [vent.ItemStateChangedEvent] - cam_hof_snap changed from raw type (image/jpeg): 732744 bytes to raw type (image/jpeg): 733504 bytes

Thanks, got it to work:

rule "send email when gif is ready - cam1"
when
    Item CamFrontdoor_CreateGif changed from ON to OFF
then
    logInfo("IP Cam frontdoor - GIF", "GIF ready and now sending email")
    val mailActions = getActions("mail","mail:smtp:myemail")
    mailActions.sendMail("myemail@mydomain.com", "Openhab IP-Cam frontdoor", "Openhab IP-Cam: ", "file:///tmpfs/camera/ipcamera.gif" )
end
1 Like

Thanks for providing the log. I can see that the control never gets sent the COMMAND to go OFF. Not an expert on the expire binding, you may need to ask in a new thread but control can be sent a state update which moves the control without sending the COMMAND. The binding needs the command to turn it off and since it is not sent the updates still occur.
So not a bug as it would work as intended if you used a rule or moved the control manually. Hopefully it is simple to fix with using the expire binding in a slightly different way.

Now it’s working.
I removed the expire definition in the item file and created a rule for the item:

var Timer cam_hof_timer = null

rule "cam hof update off"
when
    Item cam_hof_update changed to ON
then
    if (cam_hof_timer !== null) cam_hof_timer.cancel()
    cam_hof_timer=createTimer(now.plusSeconds(1), [ |
            cam_hof_update.sendCommand(OFF)
            cam_hof_timer = null
    ])
end

And i changed the setting in the PaperUI to:
image

Thanks for the help :grinning:

If i find some time today, i will give the mjpeg feature a try.

If you read the expire documentation it can send the command VS an update. Just a syntax change and it would have worked. If you update a control it is not the same as sending it a command, worth learning about when you get a chance as it will catch you out.

Shame on me…

You are right with the following item definition it is working like before without a rule:

Switch  cam_garten_update   "Kamera Garten Update"  {channel="ipcamera:ONVIF:da2a5c9e:updateImageNow", expire="1s,command=OFF" }

Thanks again :sweat_smile:

I feel a bit uncomfortable asking some “noob” questions, but I need your advise.
The binding is working great with my equipment:

  • 1 x HIKVISION NVR DS-7616-NI-K2
  • 2 x HIKVISION DS-2CD2035-I (direct or via the NVR)
  • 1 x HIKVISION DS-2CD2032F-I (direct or via the NVR)
  • 1 x HILOOK IPC-C120-D/W (via the NVR)
  • 1 x ANPVIZ PTZIP204WX4IR (direct or via the NVR)

The ANPVIZ PTZ:s presets can be controlled if I create the Thing pointing directly to the camera. Via the NVR it does nothing.

I do have to manually enter the RTSP source configuration into all the thing configurations. It does not detect it automatically. I have UPnP turned off for the cameras (actually I have upnp completely turned off on my network). Is the “auto detection” depending on UPnP?

I mainly use the binding to trigger openhab actions from alarms (directional line crossing), which I find extremely reliable compared to simple motion alarms or PIR sensors.

Since I want to be able to cast the camera streams to my Nest hubs, I have set the sub streams as H264 - instead of MJPEG. What, if any, functionality am I missing by not having a MJPEG stream directly from the cameras?

Cheers
/Daniel

Does it work via ONVIF device manager software? Need to know if it is your NVR not having the support in it or if the binding needs looking at. The PTZ support is still not fully done and I was asking for people to send in trace logs if they have issues BUT it only wastes my time if it does not work in other software hence test it with ODM. It is also possible that just by trying it in ODM it will do the setup functions my binding is missing and it will then work with the binding.

No it uses SOAP http messages on the ONVIF_PORT. No idea why, once again test it with ODM to see if the behaviour is the same in another app. I have 3 brands of cameras that all auto detect so I doubt it is a bug. Of course you cant rule out a bug in your NVR or lacking support until you try it with other software. There is nothing wrong with manually providing the urls as the binding will work just fine.

hhmmm mjpeg streams :slight_smile: Even with my 3 stream cameras I prefer to use the newer snapshots.mjpeg and that wont use CPU and you still get mjpeg. See readme for info as that is definitely worth checking out.

Could you make this configurable, if i want to use snapshots or rtsp-stream for the gif-creation, even if i use preroll?

I want to have a smooth gif with a few seconds before the movement was detected, but if i use gif-preroll, then your binding uses only snapshots instead of the steam.

That would require the stream to be running all the time. See here as I will leave gif how it is but create mp4 to be higher FPS. A lot of work to be done testing first.

1 Like

So this is not implemented in the binding yet?

Will this use more cpu power all the time?

With the current binding, will the mjpeg-stream or hls-stream (from the binding, not directly from the cam) only be produced when there is someone showing it in the browser/phone/app? Else there is used no cpu power for this, because it is sleeping? Only snapshots are processed every second?

No and it needs numerous things added to come together to work with pre-roll so this is going to take time.

Only a small amount as it just places the stream from a camera pretty much unchanged onto the disk. Of course it means increased disk activity unless you manually setup a ramdisk for ffmpeg to work in. Readme covers this. If you want a preroll feature then it has to run :slight_smile: The ability to have the HLS run non stop is what I am adding currently in what little time I have spare.

That is a complex question as there are so many different ways the binding can work depending on what camera you have. A rtsp only camera is handled differently to a camera with an API.
With a API based camera you are correct I have designed the binding to sleep when things are not needed and even the snapshots can be shut down and only fetched on demand, but with default settings the snapshots are fetched at the poll rate, the rest are only started on demand and don’t use much CPU.

With a rtsp camera that only has a h264 stream, if you want mjpeg it has the chew your CPU to create one but it is done on demand and will sleep when it is not watched. If you want to watch it on 6 tablets around your home then it only does this once and the binding makes a copy and distributes it on demand. It is pretty cool.

After turning off the snapshot feature (image channel, snapshots.mjpeg) all warnings are gone, binding is running very stable now, thanks :+1:
I have now mjpeg streaming (ipcamera.mjpeg), animated gif’s (updateGif), motion alarm and infrared led control working, that’s all I need :grinning:
Binding version 20200116.

1 Like

Did you remove the entry in your sitemap for snapshots.mjpeg or is there an additional switch, where you can set this to off?

Yes and commented out the {channel="ipcamera:DAHUA:yxyxyxyyx:image"} channel.

Hi Matt,

I tried the new binding it didn’t seem to behave as expected. I set the refresh rate to 5000ms but got more frequent updates and ran into problems. If I let it run then I got a ‘no heap space’ message and multiple messages about closing channels. See log. I have gone back to the older version which is OK.

M

2020-01-24 14:04:30.152 [INFO ] [clipse.smarthome.model.script.Camera] - Manual image updating started

2020-01-24 14:04:30.156 [ome.event.ItemCommandEvent] - Item 'GarageCamUpdateImage' received command ON

2020-01-24 14:04:30.179 [nt.ItemStatePredictedEvent] - GarageCamUpdateImage predicted to become ON

2020-01-24 14:04:30.195 [ome.event.ItemCommandEvent] - Item 'TerraceCamUpdateImage' received command ON

2020-01-24 14:04:30.206 [ome.event.ItemCommandEvent] - Item 'PorchCamUpdateImage' received command ON

2020-01-24 14:04:30.209 [ome.event.ItemCommandEvent] - Item 'IPCameraImageUpdate_Timer' received command OFF

2020-01-24 14:04:30.211 [vent.ItemStateChangedEvent] - GarageCamUpdateImage changed from OFF to ON

2020-01-24 14:04:30.228 [nt.ItemStatePredictedEvent] - TerraceCamUpdateImage predicted to become ON

2020-01-24 14:04:30.250 [nt.ItemStatePredictedEvent] - PorchCamUpdateImage predicted to become ON

2020-01-24 14:04:30.258 [vent.ItemStateChangedEvent] - TerraceCamUpdateImage changed from OFF to ON

2020-01-24 14:04:30.260 [vent.ItemStateChangedEvent] - PorchCamUpdateImage changed from OFF to ON

2020-01-24 14:04:31.499 [vent.ItemStateChangedEvent] - GarageCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:31.736 [vent.ItemStateChangedEvent] - PorchCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:32.061 [vent.ItemStateChangedEvent] - TerraceCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:32.090 [vent.ItemStateChangedEvent] - GarageCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:32.183 [vent.ItemStateChangedEvent] - PorchCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:32.246 [vent.ItemStateChangedEvent] - TerraceCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:33.772 [vent.ItemStateChangedEvent] - TerraceCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:33.796 [vent.ItemStateChangedEvent] - GarageCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:33.859 [vent.ItemStateChangedEvent] - PorchCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:35.860 [vent.ItemStateChangedEvent] - PorchCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:35.862 [vent.ItemStateChangedEvent] - GarageCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:36.675 [vent.ItemStateChangedEvent] - TerraceCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:38.504 [vent.ItemStateChangedEvent] - PorchCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:38.536 [vent.ItemStateChangedEvent] - TerraceCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:39.213 [vent.ItemStateChangedEvent] - GarageCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:42.117 [vent.ItemStateChangedEvent] - GarageCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:42.119 [vent.ItemStateChangedEvent] - PorchCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:43.041 [vent.ItemStateChangedEvent] - TerraceCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:46.484 [vent.ItemStateChangedEvent] - GarageCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:48.618 [vent.ItemStateChangedEvent] - TerraceCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

2020-01-24 14:04:55.200 [vent.ItemStateChangedEvent] - PorchCamImage changed from raw type (image/jpeg): 768000 bytes to raw type (image/jpeg): 768000 bytes

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

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

	at org.openhab.binding.ipcamera.handler.IpCameraHandler$CommonCameraHandler.channelRead(IpCameraHandler.java:757) ~[?:?]

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