Camera snapshot error using Frigate proxy

I have a script which gets called if someone presses my doorbell. This has worked for ages and sends a snapshot of my front door camera to my phone in a notification. Recently this stopped working with the below error. I’m not sure what to investigate since the camera is still working and other cameras with the exact same automation / script function perfectly.

Service call in Script (and similar with other cameras in automations)

service: notify.mobile_phones
data:
  message: Someone is at the front door
  data:
    ttl: 0
    priority: high
    image: /api/camera_proxy/camera.front_door
Error log
Logger: aiohttp.server
Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:421
First occurred: January 10, 2024 at 18:23:08 (426160 occurrences)
Last logged: 12:19:00

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 350, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
  Expected CRLF after version:

    b'POST /api/webhook/onvif98df82a57b3a HTTP/1.1 '
                                                  ^

Edit: Forgot to mention I get the notification with a image of an error saying no frames were captured.

image

This means frigate itself has errors, check the frigate logs

Yep, so here is a snip of the Frigate log. This error is getting repeated over and over.

2024-01-15 05:31:11.483410998  [2024-01-15 13:31:11] ffmpeg.front_door.detect       ERROR   : rtsp://*:*@192.168.0.102:554/ch1/third/av_stream: Server returned 5XX Server Error reply
2024-01-15 05:31:11.526041676  [2024-01-15 13:31:11] frigate.video                  ERROR   : front_door: Unable to read frames from ffmpeg process.
2024-01-15 05:31:11.526312291  [2024-01-15 13:31:11] frigate.video                  ERROR   : front_door: ffmpeg process is not running. exiting capture thread...
2024-01-15 05:31:21.491340194  [2024-01-15 13:31:21] watchdog.front_door            ERROR   : Ffmpeg process crashed unexpectedly for front_door.
2024-01-15 05:31:21.491707898  [2024-01-15 13:31:21] watchdog.front_door            ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2024-01-15 05:31:21.492069235  [2024-01-15 13:31:21] ffmpeg.front_door.detect       ERROR   : [rtsp @ 0x56532d3a5f40] method SETUP failed: 500 Internal Server Error

At the time of getting the log, that camera is not showing an image in Frigate:
image

…however it is displaying a video feed to my dashboard via the ONVIF integration:
image

…and all 3 streams (main, sub and third) are working fine via ONVIF.

Any idea what to look into next?

I just changed the detection URL for this camera from the ‘third stream’ to ‘sub stream’ and now I get an image / video in Frigate again… not sure why the third stream suddenly stopped working in Frigate though since it is still working in ONVIF…

Even with the above working now, I still have this error repeating in my HA log:

2024-01-16 12:25:05.770 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.front_door] Error from stream worker: Error opening stream (HTTP_NOT_FOUND, Server returned 404 Not Found) rtsp://ccab4aaf-frigate-fa:8554/front_door

2024-01-16 12:25:06.028 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.front_door_thirdstream] Error from stream worker: Error opening stream (HTTP_SERVER_ERROR, Server returned 5XX Server Error reply) rtsp://****:****@192.168.0.102:554/Streaming/Channels/103?transportmode=unicast&profile=Profile_3

2024-01-16 12:25:06.224 ERROR (MainThread) [aiohttp.server] Error handling request

Traceback (most recent call last):

File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 350, in data_received

messages, upgraded, tail = self._request_parser.feed_data(data)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data

aiohttp.http_exceptions.BadStatusLine: 400, message:

Expected CRLF after version:

b'POST /api/webhook/onvif98df82a57b3a HTTP/1.1 '

Interestingly this camera has now stopped working in Frigate once again… one the substream rather than third stream. It was working fine this morning…

I’ve tried restarting Frigate but that didn’t fix it.

image

Same error in Frigate log as earlier:

2024-01-16 07:06:03.637971161  [2024-01-16 15:06:03] watchdog.front_door            ERROR   : Ffmpeg process crashed unexpectedly for front_door.
2024-01-16 07:06:03.637977348  [2024-01-16 15:06:03] watchdog.front_door            ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2024-01-16 07:06:03.638243404  [2024-01-16 15:06:03] ffmpeg.front_door.detect       ERROR   : [rtsp @ 0x561878eaef40] method SETUP failed: 500 Internal Server Error
2024-01-16 07:06:03.638549891  [2024-01-16 15:06:03] ffmpeg.front_door.detect       ERROR   : rtsp://*:*@192.168.0.102:554/ch1/sub/av_stream: Server returned 5XX Server Error reply
2024-01-16 07:06:03.668178368  [2024-01-16 15:06:03] frigate.video                  ERROR   : front_door: Unable to read frames from ffmpeg process.
2024-01-16 07:06:03.668390653  [2024-01-16 15:06:03] frigate.video                  ERROR   : front_door: ffmpeg process is not running. exiting capture thread...

the camera is throwing a 500 error which means the camera has an internal failure

I was starting to think that might be the issue… time to replace it I guess. It’s not even all that old.

EDIT: I see there is a firmware update available so I’ll try that first.

Unfortunately updating the camera firmware hasn’t resolve the issue.

Still getting no video in Frigate but fine with ONVIF

Frigate:
image

ONVIF:
image

can always use go2rtc to connect via onvif for the stream

I haven’t had success with go2rtc yet. I need to spend some time trying to get that working.

Just another update on this error. I find that after multiple restarts of the Frigate add-on, I can often get the stream to load properly and then the snapshots work again. It will generally fail again after a HA server reboot and then needs Frigate add-on restarts again to get the stream going again… not sure how much that helps with determining the issue but at least I know it’s not the camera.