Integrate local Pi Camera into OpenHAB

I have I have a local camera on my OpenHAB server that I would like to integrate into OpenHAB. The camera is connected to the Raspberry Pi via the interface and I would now like to view this camera via Openhab. Does anyone know a solution to set this up? On the Internet I can only find instructions for IP cameras.

There is no raspicam add-on so you’ll first have to install something that will expose your camera as an IP camera and then use the IP Camera add-on.

I have never tried it, but there is a chance it will work already and if it does not, it won’t be hard to add this ability to the ipcamera binding. EDIT: I read through the code and actually it should work.

First test that this works in a linux command line. This is to make sure the /dev/video0 is correct and the options all work correctly before making it more complex with the binding. Since I don’t have a camera I grabbed this from a google search, find what command works if this one does not.

ffmpeg -f video4linux2 -input_format h264 -video_size 1280x720 -framerate 6 -i /dev/video0 -vcodec copy -an test.h264

Then setup the binding as a generic camera and supply the /dev/video0 as the ffmpegInputUrl config field. Secondly you will then need to change the ffmpegInputOptions to take what is needed before the -i in the above command. For example -f video4linux2 -input_format h264 -video_size 1280x720 -framerate 6

Then enable the TRACE logs for the binding as described in the ipcamera documentation under how to get help section. It will list the ffmpeg command that it is trying to run and any errors. Post this and I can see what is needed to be changed to make it work.

In theory the binding should be able to create snapshots, mjpeg and HLS streams for you, as well as record and create a motion alarm. This is so long as ffmpeg is happy opening and using the camera and it may need to open the camera multiple times if your wanting multiple features at the same time. If you’re willing to do some testing and feedback I’m confident we can get this going in a matter of days.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.