Frigate PTZ Camera Setup - Amcrest ASH41

Have spent a few days trying to set up the Amcrest ASH-41 PTZ controls in HA with Frigate and not getting too far.

Installed Frigate, MQTT and ONVIF integrations and also tried just using the Amcrest integration.

Coral USB TPU is incompatible with QNAP VMs which is a bummer but this is just a single camera, only used passively so hoping I can get by. I assume though, this also means any HW acceleration is out of the picture.

I can get the RTSP stream showing just fine in lovelace and Frigate doesn’t appear to be constraining the NAS CPU too much when monitoring the Add-On.

I’m guessing there’s something wrong with the ONVIF portion of the frigate.yaml file or ONVIF setup but not sure where I’m off…

Any tips for getting PTZ working with Amcrest ASH-41? Looking more like I’m stuck using the ancient Amcrest android app for now.

Setup:
Latest HA OS running on a QNAP NAS VM - 2GB RAM, 2 CPUs

frigate.yaml

mqtt:  
  host: 192.168.1.143  
  user: frigateMQTT  
  password: password

cameras:  
  b_camera:  
    ffmpeg:  
      inputs:  
        - path: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0&authbasic=64  
    onvif:  
      host: 192.168.1.109  
      port: 8000  
      user: admin  
      password: password

Frigate ONVIF error:

frigate.ptz.onvif              ERROR   : Onvif connection to b_camera failed: Unknown error: HTTPConnectionPool(host='192.168.1.109', port=8000): Max retries exceeded with url: /onvif/device_service (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9357c40df0>: Failed to establish a new connection: [Errno 111] Connection refused'))

Rest of Frigate Logs:

2024-07-27 23:19:01.462738944  [2024-07-27 18:19:01] frigate.app                    INFO    : Starting Frigate (0.13.2-6476f8a)
2024-07-27 23:19:01.470249774  [2024-07-27 18:19:01] frigate.app                    INFO    : Creating directory: /tmp/cache
2024-07-27 23:19:02.487847368  2024/07/27 18:19:02 [error] 157#157: *44 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /api/version HTTP/1.1", upstream: "http://127.0.0.1:5001version", host: "127.0.0.1:5000"
2024-07-27 23:19:03.710455611  2024/07/27 18:19:03 [error] 157#157: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.30.32.1, server: , request: "GET /api/stats HTTP/1.1", upstream: "http://127.0.0.1:5001stats", host: "ccab4aaf-frigate:5000"
2024-07-27 23:19:07.957287076  2024/07/27 18:19:07 [error] 157#157: *47 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /api/version HTTP/1.1", upstream: "http://127.0.0.1:5001version", host: "127.0.0.1:5000"
2024-07-27 23:19:08.396287429  [2024-07-27 18:19:08] peewee_migrate.logs            INFO    : Starting migrations
2024-07-27 23:19:08.707585380  [2024-07-27 18:19:08] peewee_migrate.logs            INFO    : There is nothing to migrate
2024-07-27 23:19:08.711086973  2024/07/27 18:19:08 [error] 157#157: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.30.32.1, server: , request: "GET /api/stats HTTP/1.1", upstream: "http://127.0.0.1:5001stats", host: "ccab4aaf-frigate:5000"
2024-07-27 23:19:11.185626951  2024/07/27 18:19:11 [error] 157#157: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.30.32.1, server: , request: "GET /api/events?cameras=b_camera&limit=50&include_thumbnails=0 HTTP/1.1", upstream: "http://127.0.0.1:5001/events?cameras=b_camera&limit=50&include_thumbnails=0", host: "ccab4aaf-frigate:5000"
2024-07-27 23:19:11.187964849  172.30.32.1 - - [27/Jul/2024:18:19:11 -0500] "GET /api/events?cameras=b_camera&limit=50&include_thumbnails=0 HTTP/1.1" 502 157 "-" "HomeAssistant/2024.7.3 aiohttp/3.9.5 Python/3.12" "-"
2024-07-27 23:19:12.682501855  [2024-07-27 18:19:12] frigate.ptz.onvif              ERROR   : Onvif connection to b_camera failed: Unknown error: HTTPConnectionPool(host='192.168.1.109', port=8000): Max retries exceeded with url: /onvif/device_service (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9357c40df0>: Failed to establish a new connection: [Errno 111] Connection refused'))
2024-07-27 23:19:12.714232987  [2024-07-27 18:19:12] frigate.app                    INFO    : Recording process started: 347
2024-07-27 23:19:12.772244368  [2024-07-27 18:19:12] frigate.app                    INFO    : go2rtc process pid: 87
2024-07-27 23:19:13.810248184  2024/07/27 18:19:13 [error] 157#157: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.30.32.1, server: , request: "GET /api/stats HTTP/1.1", upstream: "http://127.0.0.1:5001stats", host: "ccab4aaf-frigate:5000"
2024-07-27 23:19:15.580465046  2024/07/27 18:19:15 [error] 157#157: *52 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /api/version HTTP/1.1", upstream: "http://127.0.0.1:5001version", host: "127.0.0.1:5000"
2024-07-27 23:19:16.603977429  [2024-07-27 18:19:16] frigate.app                    INFO    : Output process started: 367
2024-07-27 23:19:16.621285966  [2024-07-27 18:19:16] detector.cpu                   INFO    : Starting detection process: 365
2024-07-27 23:19:17.061854179  [2024-07-27 18:19:17] frigate.detectors              WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
2024-07-27 23:19:18.554832487  [2024-07-27 18:19:17] frigate.app                    INFO    : Camera processor started for b_camera: 373
2024-07-27 23:19:18.560993110  [2024-07-27 18:19:18] frigate.app                    INFO    : Capture process started for b_camera: 375
2024-07-27 23:19:18.737763003  2024/07/27 18:19:18 [error] 157#157: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.30.32.1, server: , request: "GET /api/stats HTTP/1.1", upstream: "http://127.0.0.1:5001stats", host: "ccab4aaf-frigate:5000"
2024-07-27 23:19:23.593433114  2024/07/27 18:19:23 [error] 157#157: *55 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /api/version HTTP/1.1", upstream: "http://127.0.0.1:5001version", host: "127.0.0.1:5000"
2024-07-27 23:19:23.711088452  2024/07/27 18:19:23 [error] 157#157: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.30.32.1, server: , request: "GET /api/stats HTTP/1.1", upstream: "http://127.0.0.1:5001stats", host: "ccab4aaf-frigate:5000"
2024-07-27 23:19:43.282222512  172.30.32.1 - - [27/Jul/2024:18:19:43 -0500] "GET /api/events?cameras=b_camera&limit=50&include_thumbnails=0 HTTP/1.1" 200 3 "-" "HomeAssistant/2024.7.3 aiohttp/3.9.5 Python/3.12" "-"
2024-07-27 23:19:45.355262116  172.30.32.1 - - [27/Jul/2024:18:19:45 -0500] "GET /api/b_camera/latest.jpg HTTP/1.1" 499 0 "-" "HomeAssistant/2024.7.3 aiohttp/3.9.5 Python/3.12" "-"
2024-07-27 23:19:45.433982754  172.30.32.1 - - [27/Jul/2024:18:19:45 -0500] "GET /api/b_camera/latest.jpg HTTP/1.1" 200 92710 "-" "HomeAssistant/2024.7.3 aiohttp/3.9.5 Python/3.12" "-"
2024-07-27 23:19:45.441241439  172.30.32.1 - - [27/Jul/2024:18:19:45 -0500] "GET /api/b_camera/latest.jpg HTTP/1.1" 200 92710 "-" "HomeAssistant/2024.7.3 aiohttp/3.9.5 Python/3.12" "-"
2024-07-27 23:19:47.414695814  172.30.32.1 - - [27/Jul/2024:18:19:47 -0500] "GET /api/b_camera/latest.jpg HTTP/1.1" 499 0 "-" "HomeAssistant/2024.7.3 aiohttp/3.9.5 Python/3.12" "-"
2024-07-27 23:19:55.361992236  172.30.32.1 - - [27/Jul/2024:18:19:55 -0500] "GET /api/b_camera/latest.jpg HTTP/1.1" 499 0 "-" "HomeAssistant/2024.7.3 aiohttp/3.9.5 Python/3.12" "-"

Are you sure that camera supports onvif ptz? The similarly named Amcrest ASH21 did not support onvif. Camera Configuration | Frigate

1 Like

Thanks for the response. That’s what I saw too. No specific exclusions other than ASH21 and “some older models”. Will see what Amcrest support says about it but you may be right, I’m probably SOL.

That table is based on user feedback, so make sure you provide some to the frigate guy.

A possible idea,

One. Disable the onvif integration in HA, maybe it interferes; or

Two: disable onvif in frigate and see if the ha integration works.

1 Like

For anyone else running into this in the future, Amcrest confirmed the comparable model compatible with ONVIF is IP4M-1041W. This model is not compatible.

1 Like

I have Amcrest ASH41 and PTZ works with Frigate.
In my Frigate config, onvif port is set to 80, not 8000.

@rsiv Is the ASH41 doing everything you want in Frigate? Would you recommend it if I am looking for a PTZ compatible camera for Frigate?

Yep, pretty much. I use it to monitor my garage. PTZ and night vision work great. Don’t know about two-way audio.
I also have ASH-47 that also works fine with Frigate, although siren and light are not supported.

I have this camera working but i get many errors. ffmpeg crashes often. I think it’s due to the VBR. Does anyone else have this issue? I can’t set it to CBR.

This line of Amcrest cameras doesn’t have a web interface, but there is a tool called “Amcrest IP Config” that allows you to control VBR/CBR, resolution, framerate, bitrate, etc: https://support.amcrest.com/hc/en-us/articles/213227938-IP-Config-Software

Select your camera (or enter its IP address) and login with username admin and your RTSP streaming password. You can set it to CBR in the Encode tab.

I set mine to H.264, 15 fps, CBR, 3072 kbps.

@rsiv are you able to use autotracking with your ASH47?

No autotracking with ASH47 as far as I know.
Will try again once 0.15 is released.

how did you fare? I upgraded to 0.15 but just can’t figure out if the ASH47 will support autotracking.

Still not supported. It’s a camera limitation.

frigate.ptz.onvif              WARNING : Disabling autotracking zooming for xxx: Relative zoom not supported
frigate.ptz.onvif              WARNING : Unable to get presets from camera: xxx: Unknown error: This optional method is not implemented
frigate.ptz.autotrack          WARNING : Disabling autotracking for xxx: FOV relative movement not supported

Yep. Thanks. This is what I was seeing as well. Just wanted to confirm that I wasn’t misconfiguring the config.

Did you figure this out with the ASH41? I’ve been seeing similar ffmpeg crashes. I used a similar tool to what @rsiv described - Amcrest Surveillance Pro. I was able to adjust the camera fps, bit rate, CBR vs VBR, etc.

Can either of you share some of your working config / ffmpeg arguments so I can compare?

I assume you’re also using h.246 on the camera because go2rtc doesn’t work with h.256? At least that was my thinking. I also tried h.246b - still kinda unstable for ffmpeg.

Here is my camera:

go2rtc:
    LIV:
      - rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0&authbasic=64
      - ffmpeg:LIV#video=copy#audio=opus
    LIV_detect:
      - ffmpeg:LIV#video=copy

Thanks!

Just saw your question. Here is my config for the ASH41 if you are still having issues. Camera is configured to H264.

go2rtc:
  streams:
    garage:
      # Amcrest ASH41-W
      - rtsp://admin:{FRIGATE_AMCREST_PASSWORD}@192.168.xx.yy:554/cam/realmonitor?channel=1&subtype=0&authbasic=64
      - ffmpeg:garage#audio=opus

cameras:
  garage:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/garage
          input_args: preset-rtsp-restream
          roles:
            - detect
            - record
            - audio
    onvif:
      host: 192.168.xx.yy
      port: 80
      user: admin
      password: '{FRIGATE_AMCREST_PASSWORD}'
    record:
      enabled: true
    detect:
      enabled: true
      width: 1280
      height: 720
      fps: 5