Use ffmpeg to take snapshot

I recently accutred this camera from aliExpress:

I want to use it to take a snapshot whenever someone rings my doorbell, so that I can send it to my phone.

I figured out that it can be reached at rtsp://admin:[email protected]:554/onvif1, I can play the stream in VLC.

I also figured out that with FFMPEG I can take a snapshot if I use this code:

ffmpeg -i rtsp://admin:[email protected]:554/onvif1 -f x11grab -framerate 1 -video_size 656x416 -i :0.0 -vframes 1 output.jpeg

So I figured I could make a shell command out of this, and us that to save the snapshot somewhere. The only problem is, that taking a snapshot takes a lot of time, I read here https://www.home-assistant.io/components/ffmpeg/#troubleshooting that ffmpeg does some kind of autodetection, so maybe thatā€™s whatā€™s taking a lot of time. The output from the command looks like this:



Taking the snapshot does work, but it can take over 40 seconds. Any idea if I can give ffmpeg more options to speed up this process?

I used a similar ffmpeg process to get snapshots for notification (not high resolution):

 ffmpeg -rtsp_transport udp -i "rtsp://192.168.1.$camip:8082/h264_ulaw.sdp" -vf fps=1/3 -pix_fmt yuvj420p -s 320x240 -nostdin -loglevel panic -strftime 1 photo_"%Y%m%d%H%M%S.jpg"

It takes 2-3 seconds to save the jpg file from the live stream in my case. The factors I noticed were source resolution and network speed.

Thanks, I slightly modified your command, and changed it into this:
ffmpeg -rtsp_transport udp -i "rtsp://admin:[email protected]:554/onvif1" -vf fps=1/3 -pix_fmt yuvj420p -s 656x416 -nostdin photo.jpg -y -loglevel 0

Iā€™s now quite a bit faster, although it still takes up to 5 seconds for a snapshot, but maybe thatā€™s because the camera is just a bit slow.

Thatā€™s great, glad it works.

Iā€™m looking to replace my IP Webcam front door cam, does this cam work without using their app and account? Any other problem using this with HA?

Well, Iā€™m not yet sure if Iā€™m satisfied with this cam. I took me a lot of trouble to get it on the wifi. You have to use the yoosee app to get it configured. The app was constantly telling me that connecting to the wifi failed, after I while I checked my router and I saw in there that a new IP was actually given to a device, turned out wifi was working properly, but the app is just a bit buggy.

After getting the IP from the camera, I was able to fetch the stream on rtsp://admin:123@/onvif1 and I no longer needed the app.

I did not yet figure out if the camera has a still image url, that would be quicker than fetching the image from the stream.

The camera seems to be a bit slow (thereā€™s a 2 second delay between what happens, and what the camera shows), also it comes with some annoying cabling:

a bit hard to get those installed out of sight. A last issue I have with the camera is that the cable from the power adapter is very short, also a bit annoying.

Iā€™m now going to run the camera for a week anyway, to see how it does as a snapshot camera.

Just chiming inā€¦
Iā€™ve had a couple of these cameras for about 2 years now.
Have run into the same issues as mentioned in this thread.

Having had the same issues as mentioned in this thread, I decided to experiment with the wired network port. The camera behaves in exactly the same way as when accessed through wifi. Always a few seconds delay, and sometimes the image is distorted.

The only thing that helps is accessing the low-resolution stream. Even then, sometimes the first image is distorted, but the subsequent frames are always good.

Solution ? Always grab 2 frames, and discard the first one.

The dealbraker for me, is the fact that these ā€˜Yooseeā€™ cameras are calling home to a whole bunch of China-based servers, and there is no way of blocking this without crippling many of the cameraā€™s features.
If you firewall the cameras they begin to spam your network in attempts to reach out to the mothership, talking about hundreds-of-thousands of requests per day !!!
This then slows down the camera even moreā€¦

Iā€™m still on the look-out for a cheap, reliable, safe camera compatible with Home Assistant.

Thanks for sharing your experience Tommmii, the things you figured out where exactly the things I had in mind to test, so you saved me a lot of time :slight_smile:

The ā€œcalling homeā€ that this camera probably also does (have to check it) will be a deal breaker for me, maybe I will switch to a Foscam FI9800P (that does have a still image url, which makes it much easier to take a snapshot)

except that the Foscam devices cost 5-6 times more than those Yoosee things.
There are 20-40ā‚¬ ā€œYooseeā€ cams around that have a web interface, you can disable the P2P options, these ones do not call home, and also allow accessing a still image.

Thing is, they are hard to discover on the usual Chinese marketplaces, because of incomplete descriptions by most sellers. There are hundreds of listings to read through, and yo need to read all the feedbacks as wellā€¦ just to end up with a few possible candidates.

True, those foscams are a bit more expensive, but the FI9800P is only 3 times more expensive (around ā‚¬ 75).

How did you by the way grab the second frame from the video stream?

My current command is:

ffmpeg -rtsp_transport udp -i "rtsp://admin:[email protected]:554/onvif1" -vf fps=1/3 -pix_fmt yuvj420p -s 656x416 -nostdin photo.jpg -y -loglevel 0

I tried it the ā€œstupidā€ way, by just executing this command twice, but that didnā€™t seem to work. The ffmpeg command has quite a lot of options, but I couldnā€™t find the proper one to grab the second frame.

Youā€™ve made me revisit my script, turns out my memory was mistaken,
this is what iā€™m using :
avconv -i rtsp://192.168.11.12/onvif2 -frames:v 1 /home/pi/camera.jpg > /dev/null 2>&1

Ah, using a different command, Thanks! Iā€™m going to give it a try before I get another camera :slight_smile:

probably dummy question but I canā€™t figure it out

it gives me command not found return 127

how can I use avconv inside HASSIO ? Any special process?

How do you get this to work in Hassio?

I want to know how to get this to work in hassio too

1 Like