ep1cman / unifi-protect-backup

Python tool to backup unifi event clips in realtime
MIT License
633 stars 31 forks source link

G4 Doorbell ring event triggers errors and fails to backup #91

Closed Swallowtail23 closed 11 months ago

Swallowtail23 commented 1 year ago

Description

A "ring" event triggers three errors and records a zero-byte file

What I Did

2023-05-15T15:09:18.878730473+10:00 stderr F 2023-05-15 05:09:18 [   ERROR   ] unifi_protect_backup.utils                 :  Failed to run: 'ffprobe -v quiet -show_streams -select_streams v:0 -of json -
2023-05-15T15:09:18.878780902+10:00 stderr F 2023-05-15 05:09:18 [   ERROR   ] unifi_protect_backup.utils                 :  stdout:
2023-05-15T15:09:18.878780902+10:00 stderr F    {
2023-05-15T15:09:18.878780902+10:00 stderr F
2023-05-15T15:09:18.878780902+10:00 stderr F    }
2023-05-15T15:09:18.878850181+10:00 stderr F 2023-05-15 05:09:18 [   ERROR   ] unifi_protect_backup.utils                 :  stderr:
2023-05-15T15:09:18.878850181+10:00 stderr F
2023-05-15T15:09:18.880247257+10:00 stderr F 2023-05-15 05:09:18 [  WARNING  ] unifi_protect_backup.downloader            : [6461be7601446903e401a9d8]      `ffprobe` failed
2023-05-15T15:09:18.880247257+10:00 stderr F Traceback (most recent call last):
2023-05-15T15:09:18.880247257+10:00 stderr F   File "/usr/lib/python3.10/site-packages/unifi_protect_backup/downloader.py", line 190, in _check_video_length
2023-05-15T15:09:18.880247257+10:00 stderr F     downloaded_duration = await get_video_length(video)
2023-05-15T15:09:18.880247257+10:00 stderr F   File "/usr/lib/python3.10/site-packages/unifi_protect_backup/downloader.py", line 35, in get_video_length
2023-05-15T15:09:18.880247257+10:00 stderr F     raise SubprocessException(stdout, stderr, returncode)
2023-05-15T15:09:18.880247257+10:00 stderr F unifi_protect_backup.utils.SubprocessException: Return Code: 1
2023-05-15T15:09:18.880247257+10:00 stderr F Stdout:
2023-05-15T15:09:18.880247257+10:00 stderr F {
2023-05-15T15:09:18.880247257+10:00 stderr F
2023-05-15T15:09:18.880247257+10:00 stderr F }
2023-05-15T15:09:18.880247257+10:00 stderr F
2023-05-15T15:09:18.880247257+10:00 stderr F Stderr:
2023-05-15T15:09:18.880247257+10:00 stderr F
Swallowtail23 commented 1 year ago

Note all other events record and backup OK

ep1cman commented 1 year ago

Very interesting, does this happen for ALL events from the camera or just particular ones?

I have noticed with my wifi based unifi cameras (doorbell included), when the signal isn't great unifi protect will actually fail to produce video for certain time stamps

Swallowtail23 commented 1 year ago

Only for doorbell presses. So the G4 doorbell records and uploads the motion event up to the press, then spits the errors when the doorbell itself is pressed, triggering a ring event. Unifi Protect has the doorbell event, with video, OK.

ep1cman commented 1 year ago

Could you download the video via the UI and send it to me via githubissues@goscik.com?

From that logging output, it looks like ffprobe is not able to find a video feed in the file that was downloaded.

If the one from the UI is fine we might need to make some modifications to the code to save that file that was downloaded to investigate further.

Swallowtail23 commented 1 year ago

Oh now that IS interesting... the video plays fine in the UI, but downloads as a 1KB MP4 which is (obviously) not playable. Looks like the error is valid...

Swallowtail23 commented 1 year ago

It's not all ring events, just most - randomly one will be OK, I'm unable to work out what the differentiator is.

ep1cman commented 1 year ago

I have experience the same with G3 instant cameras. I attribute it (possibly incorrectly) to issues with the wifi signal dropping packets, or possibly unifi protect itself dropping frames somehow. I've never seen it on wired cameras though, only wifi ones with signal issues.