IpCamera: New IP Camera Binding

There was a bug that was fixed in 3.1 milestone3 that would have stopped it.

Ok, I am using 3.1, manually installed, do you want me to test anything? Do you want logs etc?

Hi,
I need to connect ONVIF IP camera using its name instead of ip address. If IP address is filled in the .things file it works. If I fill domain name it doesn’t. The message is We hit an issue parsing
 But the url seems to be right. Thanks in advance
Lukas

[DEBUG] [amera.internal.onvif.OnvifConnection] - We hit an issue parsing url:>http://172.16.172.148/onvif/Media
2021-04-22 18:22:18.856 [DEBUG] [amera.internal.onvif.OnvifConnection] - We hit an issue parsing url:>http://172.16.172.148/onvif/PTZ
2021-04-22 18:22:19.080 [DEBUG] [amera.internal.onvif.OnvifConnection] - GetStreamUri:rtsp://172.16.172.148:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1

You did not post which version of 3.1 your using. Probably the easier way if you dont know is to just use the version that I build and uploaded here which will work on all 3.x versions.
Note that the first time the control is moved it wont work unless you add a REFRESH command to be sent to the channel when the thing comes online. This is known and will need a fix done at some stage.

Index of /openhab/IpCameraBinding/ (pcmus.com)

@Lukas_Zich

I was using the binding a while back with a hostname instead of an IP so I suspect >95% of the code will work and it may only be the auto detection of the URLs that has an issue. I suggest you use the URL over ride parameters and you can use the same autodetected urls the binding is finding, just swap the IP for the hostname you wish to use. I suspect it will then work fine. Can you raise this as a github issue with the results of this testing please?

@matt1

Hello matt1,

I use your binding for 2 cameras, I noticed that your binding leads to a crash of openhab for me.
When i delete your binding openhab3 works well.

the following error comes after a few hours, but sometimes earlier

2021-04-24 00: 20: 10.190 [WARN] [ab.core.internal.events.EventHandler] - Dispatching event to subscriber 'org.openhab.core.internal.items.ItemUpdater@a965f' takes more than 5000ms.

I use:
openhab 3.1.0M3
Openhabian 1.6.4
Raspberry 4 B

maybe I configured something wrong, here is my config.

Camera 1

Camera 2

and i always get in the log

2021-04-24 17:31:05.353 [WARN ] [era.internal.handler.IpCameraHandler] - !!!! Camera possibly closed the channel on the binding, cause reported is: Connection reset by peer

Your best to open a new thread and post trace level log of when a single camera connects and does the long handshake with onvif messages. Also it would be worth setting the cameras up as non onvif generic cameras to see if the issue stops to narrow down if the cause is onvif related.

hi, i try to find the swith “updategif” but i can’t find them, so i decide to add a channel like this “{channel=“ipcamera:generic:CameraPortail:updateGif”}” but no chance , it don’t work , how i can add the “switch updategif” ? i test 2 things one rstp and one onvif , same things , i miss somme things ?
thanks for your help

IP Camera - Bindings | openHAB

Thanks a lot! I read all the link : GitHub - Skinah/IpCamera: A binding for Openhab 2 that allows you to use IP Cameras without the need to disable authentication. and nothing speak about,

Thanks again!, also when I press the snapshot switch I can see request on Trace log, but the snapshot is not updated, the ffmpeg is working correctly, I place the rstp url of my blue iris server and I can see through port 54200 the mpeg video, can you help me also on this?

Hey folks,

I’m asking for support for XMeye cameras as many cheap but powerful cameras and NVRs are made using this App respectively the sofia protocol.

Protocol descriptions and a communication program in python is located in this repo:

What do you think about this?
May there be tasks I (with limited java skills) can do?

Best,
Sascha

I have a Foscam FI9912P that has an MJPEG stream. Its picture is shown as 4:3, but it’s clearly an 16:9 image. Is it possible to display it as 16:9 in the sitemap?

Not sure if you would want to stretch the picture and distort how people look, ie make them look fat. Or if you wish to CROP and throw away some of the picture. If it is a MJPEG source then it is not too difficult (low CPU) to get ffmpeg to do which ever of the two you are wishing to do. The stretching can be done using a widget and CSS to stretch it when viewed by the browser.

Another solution would be to use ffmpeg to create the MJPEG from the h264 source and this would use high cpu, you enter in ‘ffmpeg’ as the source and this is covered in the bindings docs.

So there would be four ways to achieve what your wanting to do.

Thanks! Went with the ffmpeg approach, resizing the MJPEG stream. CPU usage is about half of what transcoding the rtsp stream takes. The 4:3 image was actually distorted, 16:9 is what it should be.

Hi, i already use my cam and this binding to provide me an email with a recorded gif, when someone rings the bell.

This is working fine.

Now i tried to use mp4 instead of gif. I changed the Action-command. But i only get files with 0 bytes.

Is there something i have to change? Do i have to add someting into the things-file?

First line alone is working, second line gifs me a file with 0 byte.

getActions("ipcamera", "ipcamera:dahua:CamEingang").recordGIF("ipcamera",20)
getActions("ipcamera", "ipcamera:dahua:CamEingang").recordMP4("ipcamera",20)


**and my email-command:**
mailActions.sendMail("xxx@gmail.com", "Openhab IP-Cam HaustĂŒr", "Openhab IP-Cam", "file:///tmpfs/camera1/ipcamera.gif" )
mailActions.sendMail("xxx@gmail.com", "Openhab IP-Cam HaustĂŒr", "Openhab IP-Cam", "file:///tmpfs/camera1/ipcamera.mp4" )
    

And second question: How can i send me an email with a jpeg picture instead of a gif-file, when someone rings my bell?

I’m trying to get ffmpeg working for a little while now. The latest issue I am running into: ffserver is no longer available except if I install an older version and compile it all myself. Is there any alternative that works on a raspberry pi?

This docker container is very useful: GitHub - eroji/rtsp2mjpg: RTSP to MJPEG stream conversion using FFmpeg and FFserver. It also works on the Pi (use the Dockerfile.armhf)

It is not needed if you follow the documentation on the ipcamera binding. The binding can do it.

Thanks for your response. It turned out to be the Thing that was faulty. Various things: /etc/openhab2 still in the configuration which I couldn’t modify through the UI. URLs like the MJPEG-URL were not discovered either. Deleting and then rediscovering made it work.
So if your cam doesn’t work under openhab 3, don’t hesitate to delete the thing and start again. Saves you time.
I’ve got a Dahua DH-SD59225U-HNI which now works well including motion detection alarm and cross line detection. So that model can probably be added to the list of supported devices.

2 Likes

Hi ulij, happy to see your camera works as expected. I’m not so lucky, as I can’t get my Imou IPC-A22EP (a Dahua’s consumer brand, as I know) to work in openHAB 3
I always get log “The alarm stream was not running for camera 192.168.0.214, re-starting it now”.
Can you please share your settings of camera in .things and .items file?
If I only want to get the camera’s alarm (face detected, motion detected
) then do I need to install FFmpeg, FFserver of something?
Thank you in advance!

Hello

I created the Thing and the items entirely through the openhab ui, so there are no thing or item files I could share.
However, the json code of the thing looks as below.
I did see the same error message and it disappeared once I got the serverPort right. It is important that it is not blocked by any firewall.
It’s also a good idea to increase the log level of the ipcamera binding to trace because then you see the results of the onvif discovery.
Also, the ffmpegOutput must be a directory where openhab has full access. And yes, I think you do need to install ffmpeg for streaming.

UID: ipcamera:dahua:1921681153
label: PTZ North
thingTypeUID: ipcamera:dahua
configuration:
mjpegOptions: -q:v 5 -r 2 -vf scale=1920:1080 -update 1
ipAddress: 192.168.1.153
updateImageWhen: “0”
mjpegUrl: ffmpeg
onvifPort: 80
gifPreroll: 0
ffmpegLocation: /usr/bin/ffmpeg
serverPort: 8081
ffmpegOutput: /etc/openhab/html/camera1/
ipWhitelist: DISABLE
mp4OutOptions: -c:v copy -c:a copy
pollTime: 1000
password:
port: 80
nvrChannel: 1
snapshotOptions: -an -vsync vfr -q:v 2 -update 1
ptzContinuous: false
onvifMediaProfile: 0
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
username: admin
location: Outdoors