Camera snapshots are captured wrong, is it a camera or config issue?

Hey guys,
I’m using the camera.snapshot service to send myself images of my front door but the image is captured like this:

It’s a tp-link Tapo cam C200.

Is it a cheap camera issue or is there something I can configure in hassio perhaps?

Try lower frame rate from camera or lower resolution.

1 Like

seems like maybe the camera file wasn’t completely written to the file before you tried to send it.

There doesn’t seem to be any way to synchronized a script/automation with the completion of the snapshot service, so maybe you can try to insert a short delay: 1 action in your automation before you try to send the image?

Just a guess…

I don’t think it has anything to do with the time delay between taking the capture and then sending the notification.
The snapshot is shot and then the notification is just a link to the file. Which is saved in my directory distorted like that.
Several of them are being saved like this and like 1 out of three are OK.

I dont think i know how to do this but ill give it a try and report back.

I’ve been experiencing the same problem with this camera.

I chose stream2 (360p) over stream1 (1080p). I also added ffmpeg extra_argument.

camera:
  - platform: ffmpeg
    name: Salon
    extra_arguments: '-q:v 1'
    input: rtsp://me:[email protected]:554/stream2

I have them set up as onvif, idk if that changes anything.

  - platform: onvif
    name: "DN LR Entrance Cam"
    host: xx.xx.xx.xx
    username: !secret tapo_un
    password: !secret tapo_pw
    profile: 0
    port: 2020

Did that fix the screenshots for you?

I had the same kind of bad preview in my Picture Entity Card with the onvif platform, until I lowered the resolution with ffmpeg camera platform. I guess that HA calls the camera.snapshot service to display the card.

I never encountered any problem with the card or picture notification since then.

I forget good explanation of technical cause but basically the image is being taken in as input but input device is reading faster than output can provide. This cause the “tearing” you see where basically the last lines are duplicated by input device (notice how everything after top third is same?

So. You may handle by sloe down input device read or speed up output device (camera) sending. To speed this output you can reduce image size to take less time sending(reduce frame rate on input or output can help I think but reduce image,1080 to 360 for example, does same)

Some camera have 2 or 3 stream. Like high resolution stream and lower resolution stream. Lower resolution ifor send to mobile is more than enough since image on mobile so small anyway…

Must check if another stream is possible

As @tmjpugh said, you could try to use a different profile to lower the quality.
As indicated in this configuration guide, you have 2 streams on your camera.

  - platform: onvif
    name: "DN LR Entrance Cam"
    host: xx.xx.xx.xx
    username: !secret tapo_un
    password: !secret tapo_pw
    profile: 1
    port: 2020

This way you using your camera, throughout HA, in low quality right?

correct, i think profile:1 is the low quality, and 0 is the 1080p but doesnt this defeat the purpose of having 1080p cameras? :stuck_out_tongue:

Right, the profile 0 has the highest quality and it is the profile used by default. However, the Raspberry Pi hardware isn’t able to render the highest quality image in real-time.

So, I totally agree with you !

I’m using an Asus tinkerboard S. Still not enough horsepower right?

I guess it’s not powerful enough either… However I found an interesting topic about serving full rate great quality stream with HLS, with absolute no encoding (low CPU).

I just tested it and it works great with vlc. It should works with the Chrome Extension too.

ffmpeg -i rtsp://me:[email protected]:554/stream1 -acodec copy -vcodec copy -an -f hls -hls_flags delete_segments stream.m3u8

yes and no

Camera for security have 3 general use case.

  • Detection - The ability to detect if there is some ‘thing’ vs nothing.
  • Recognition - The ability to recognize what type of thing it is (person, animal, car, etc.)
  • Identification - The ability to identify a specific individual from other people

so it ultimately depend on your use case

You sending this image as part of notification?

Maybe sending snapshot not needed and just send camera image directly. I am think you doing something like doorbell/motion>>snapshot>>send_image but maybe doorbell/motion>>send_image is enough. like @lmamakos say, maybe it sending image before finish write image to file…sending from camera directly it just takes the current camera frame and send so I never have this issue.

Has anyone managed to get the Tapo C200 camera working as a ‘generic’ camera in HA?

I’ve tried and am getting this error:

2020-04-07 12:50:18 ERROR (stream_worker) [libav.rtsp] method DESCRIBE failed: 401 Unauthorized

The same thing happens to me (Wyze Camera). However, when I checked the Media folder, it’s captured like that i.e. corrupted. If it was fully formed in the Media folder but malformed when received, it would suggest timing issue between taking the snapshot and sending it out.

I don’t think we should lower the resolution of the feeds just for the snapshots to work. There must be a better way to preserve the high quality video stream without getting malformed snapshots. These all sound like workarounds to me.

The snapshot utility of Home Assistant should really be fixed to avoid this sort of bug.

webrtc between camera and HA. this may be better anyway.
then add the camera to HA through webrtc and snapshots will likely work without issue

Thank you for the recommendation. I will check it out.

Had the same issue with onvif/Tapo Camera Control integration. Built in generic camera integration fixed this issue for me.
Installation guide:

  1. Settings → Devices & Services → Add integration
  2. Search for Generic Camera
  3. Enter RTSP stream URL.
    rtsp://username:password@IP Address:554/stream1
  4. Skip other options and Save settings.
1 Like