How to configure a hacked Xiaomi Dafang to work with OpenHAB

Have you tried this method at all? If it works in VLC then I would be surprised if these steps wont work.

Ok people, I managed to get video stream from Hacked Dafang in OpenHab (also in iOS app)!!

First need to transfer video through ffmpeg. As described in here:

On camera You need to set stream server as H264. Then start ffmpeg:

nohup ffserver &
nohup ffmpeg -i rtsp://xxx.xxx.xx.xxx:8554/unicast http://127.0.0.1:8090/camera1.ffm &

as xxx You nedd to eneter Your camera IP adres.

Then in sitemap You need to use Webview

Webview url="http://xxx.xxx.xx.xxx:8090/camera1.mjpg" height=5

here xxx must be IP adres of ffserver (like openhabian).

And You will get Your stream working!:wink:

I have had similar issues displaying video with my foscams. One of the big issues is that the RTSP feeds have a big delay on them, which is not very useful for live video feeds.

The way I solved it is to use motion (which Iā€™m sire you are familiar with) https://motion-project.github.io/ but I changed the motion source code to read directly from my foscam firmware. This isnā€™t a Foscam firmware hack, Foscam has an undocumented low level (socket level) access to the h264 video feed (and other features).

So I added access to this video feed to motion, and then serve up the mjpeg feeds from motion (at 640x480 resolution) via web pages. These web pages can be embedded in any Openhab page using the Webview widget in the sitemap. Works on everything I have tried, web, IOS, classic UI etc. (I havenā€™t tried android).

I also use motion for motion detection, motion tracking (with my foscam pan-and-zoom cameras), etc, all the usual motion good stuff.

You could do this with the normal motion interface (which supports RTSP), I didnā€™t use that interface because of the 20s lag on the foscam RTSP feed, but there may not be the same lag on other cameras.

This is similar to the ffserver/ffmpeg method, but motion is designed for cameras, can handle multiple cameras, and allows lots of customization, text overlays (I overlay the weather), motion highlighting, motion detection, motion tracking (if you have the right interface - I added my own foscam one), and is intended to run as a daemon.

Itā€™s a bit processor intensive, running 5 cameras takes about 60% of one of my (2.4GHz) server cores, but overall, thatā€™s not bad.

Iā€™ve attached some pictures of what it looks like, the screenshot is of my iPad (live 640x480 video) - recordings are in full HD.20190112-114702

The other nice thing is that because itā€™s served up in a web page, you can lay it out how you like, and make actions if you click on an image. Here there are 4 live video feeds, clicking on any of them zooms the video feed to full screen, click on it again, and it goes back to the 4 up display. You need your own web server, and a little html skill, but not too much, and most people running OH2 have their own web server.

Hope this helps!

2 Likes

@Nicholas_Waterton
Motion is definitely a good way to go especially if you have multiple cameras and if they donā€™t have motion detection available via an API then it is a must to check it out. I have stumbled onto people who are using ffmpeg and a filter to do motion detection via scripts, but people who use it say the detection is not great and the Motion project has far better motion detection then using that hack method.

What may interest you is that the IpCamera binding now has ffmpeg features built in which allows you to cast your camera feeds to chromecasts with no scripts, no extra servers and it should work on all platforms not just linux.

My Dafang should arrive soon so Iā€™m going to start watching this thread

Hi all,
My V2 cam is working fine and the integration in OH2 is working too. So good so far.
The motion detection via MQTT is working and I got an picture in PaperUI. Thanks

Now Iā€™m trying to deactivate the motion detection by a rule, but I found no command to get it deactivated.
I have a thing like this:

Type switch : motion ā€œMotion Detectionā€ [ stateTopic=ā€œzennix/ipc1/motion/detectionā€, commandTopic=ā€œzennix/ipc1/motion/detection/setā€ ]

and a Item like this:

Switch IPC1_motion_detection ā€œIPC1 Alarmā€ {channel=ā€œmqtt:topic:Mosquitto:IPC1:motionā€}

This item is added to a PaperUI control to send On or OFF to the Item. But the motion detection will not deactivate.
What is wrong in my construct?

Thanks / Zennix