Hacking the XiaomiFang Wifi camera

How is your stream? Mine is choppy with the standard settings you listed.

Also, what ffmpeg did you install?

1 Like

Stream’s alright, not great, but not choppy either. It’s smooth on the phone and laptop.
Don’t remember the ffmpeg version. Will check and let you know.

I’d installed libav-tools by sudo apt-get install libav-tools

Now with ffmpeg -version I get the following:

avconv version 11.9-6:11.9-1~deb8u1+rpi1, Copyright (c) 2000-2017 the Libav developers
built on Apr 26 2017 06:57:28 with gcc 4.9.2 (Raspbian 4.9.2-10)
avconv 11.9-6:11.9-1~deb8u1+rpi1
libavutil 54. 3. 0 / 54. 3. 0
libavcodec 56. 1. 0 / 56. 1. 0
libavformat 56. 1. 0 / 56. 1. 0
libavdevice 55. 0. 0 / 55. 0. 0
libavfilter 5. 0. 0 / 5. 0. 0
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 0. 0 / 3. 0. 0

Yes, you can with the following script.

#!/bin/sh
export DATETIME=`date +%Y%m%d%H%M%S`
ffmpeg -loglevel fatal -i rtsp://10.1.1.110/unicast -vframes 1 -r 1 /home/pi/snapshots/$DATETIME.jpg

Adapted from domoticz forum post

1 Like

hm strange. When I use your script I get this:

pi@hassbian:/home/homeassistant/.homeassistant/config $ bash snapshot.sh
'jpgle to find a suitable output format for '/home/pi/snapshots/20170529163929

There’s a better way now, thanks to @touliloup

1 Like

Just stumbled onto this post. I would be interested to hear comments on how the cameras are working for you so far, but my real question is: Is there a way to turn the cameras off somehow? I would rather not be streaming or recording when we are home.

Are you saying with the hack you can not only view the camera stream on HA but also listen to any sounds from the live stream? As the camera has a built in mic and speaker, so I suppose you could also talk from HA and get the output from the camera’s speaker?

1 Like

The camera is working fine. I have a couple around the house with the hack and no issues whatsoever.

I haven’t really tried to turn them off. Will try different settings and let you know.

Haven’t tried that either. My primary intention was for the camera not to connect to china. The hack satisfies that.

1 Like

@Mukund That would be great if you can try to see if there is a way to turn it off or stop streaming … I think that they are cute cameras and I could see the use of stacking 2 of them together in some areas. Keep us posted if you can.

I did all. It works well on VLC (rtsp://IP/unicast), also well in Tinycam pro.

but is not working in HASS, no matter the commands I use.

I think have a problem with ffmpeg component, not sure how to solve

what about this – Rtsp stream support for camera

I run a windows 7 VM on my QNAP and then use contacam to convert the rtsp feed into a jpg which works perfectly in HA. I do that for 2 camera that only have rtsp as I found rtsp in HA was god damn slow. I use the VM as my backup server, so now I have found another use for it :slight_smile:

Only issue with this and the hack is the nightvision is just rubbish, blocky/grainy black and white. Is this normal ?

Cheers
Mark

hi i got my cam today and followed the tutorial. Well … I cannot see anything in vlc… no connection could be etablished … do i have to deactivate the cloud? the hack is running on the cam

ok works… but home assistant (hassio) freezes and breaks down when trying to watch the stream

Are you using the RTSP or MJPEG stream?
I have been using the RTSP and its working OK on my hass.io install… but am running hass.io on a VM on xeon server, so has much more cpu etc for ffmpeg to process the 1080p stream from the xiaofang.
BTW the out of box ffmpeg provided in hass.io image is working fine, but I noticed that the rtsp server on the camera is not very stable and often quits :frowning:

I’m going to try the MJEPG version of the xiaofang hack linked above.

it is easier as expected to integrate xiaomi cam into hass This can be archieved by Motioneyeos . just add the cam, after installing the hack on it, as network camera and use the streraming link in motioneyeos to stream the video.

@hijinx it might be issue with ffmpeg and raspberry cause when i add this cam with rtsp my whole system freezes. Would u mind telling us how u made it?
This Method seems to be only jpeg and i want a stream not a dia show.

I did the following:

When I go the the group I can see the camera’s feed as a still.
When I click on the still image it opens an overlay card with a live (transcoded) image.

I’m just using the ffmpeg that comes pre-deployed in the hass.io home assistant container.

I can see that ffmpeg is using CPU (using top command from in the homeassistant container, and also on the esxi performance monitor) constantly whilst streaming as it’s transcoding the video.
My guess is that my x86 server has the power to do a transcode, but that RPi does not.
Nonetheless I found that the snx_rtsp_server (RTSP server) process running on the camera seems to die often :frowning:

I’m not at home right now, but I can post the exact yaml later if you like?

thanks for your response… thats exactly the way i did it too. some users say it would work but more I read it doesnt work… so i made my descission to take motioneyeos to transcode the video :slight_smile: thanks anyway… thought i’d find a snipped i missed… but we have done exactly the same thing