Repository: blakeblackshear/frigate

Issue:
[Support]: Recording error, OpenCV returns N/A
### Describe the problem you are having

recording stops after opencv exception.

### Version

0.13.0-A490C375

### Frigate config file

```yaml
mqtt:
  # Optional: Enable mqtt server (default: shown below)
  enabled: false
  # Required: host name
  host: mqtt.server.com
  # Optional: port (default: shown below)
  port: 1883
  # Optional: topic prefix (default: shown below)
  # NOTE: must be unique if you are running multiple instances
  topic_prefix: frigate
  # Optional: client id (default: shown below)
  # NOTE: must be unique if you are running multiple instances
  client_id: frigate
  # Optional: user
  # NOTE: MQTT user can be specified with an environment variables that must begin with 'FRIGATE_'.
  #       e.g. user: '{FRIGATE_MQTT_USER}'
  #user: mqtt_user
  # Optional: password
  # NOTE: MQTT password can be specified with an environment variables that must begin with 'FRIGATE_'.
  #       e.g. password: '{FRIGATE_MQTT_PASSWORD}'
  #password: password
  # Optional: tls_ca_certs for enabling TLS using self-signed certs (default: None)
  #tls_ca_certs: /path/to/ca.crt
  # Optional: tls_client_cert and tls_client key in order to use self-signed client
  # certificates (default: None)
  # NOTE: certificate must not be password-protected
  #       do not set user and password when using a client certificate
  #tls_client_cert: /path/to/client.crt
  #tls_client_key: /path/to/client.key
  # Optional: tls_insecure (true/false) for enabling TLS verification of
  # the server hostname in the server certificate (default: None)
  #tls_insecure: false
  # Optional: interval in seconds for publishing stats (default: shown below)
  #stats_interval: 60

logger:
  logs:
    frigate.object_detection: debug
detectors:
  #armnn:
  #  type: armnn
  #  num_threads: 4
  #  model:
  #    path: //cpu_model.tflite  # used by default.
  #    #path: //yolov5s_f16.rknn
  #    labelmap_path: //labelmap.txt
  #    width: 320
  #    height: 320
  #rknn:
  #  type: rknn
  #  path: //models/yolov5s-640-640.rknn
  #  #path: //ssd_mobilenet_v1_coco.rknn
  #  labelmap_path: //models/yolov5s-640-640.txt
  #  #labelmap_path: //labelmap.txt
  #  width: 1280
  #  height: 1280
  #  width: 640
  #  height: 640
  #rknn2:
  #  type: rknn
  #  path: //yolov5s_f16.rknn
  #rknn3:
  #  type: rknn
  #  path: //yolov5s_f16.rknn
  #rknn:
  #  type: rknn
  #  num_threads: 3
  #  path: //yolov5s_f16.rknn
  #  labelmap_path: //labelmap.txt
  #  width: 640
  #  height: 640
  #rknn2:
  #  type: rknn
  #  path: //rockchip_1808.rknn
  #  width: 640
  #  height: 640
  #rknn3:
  #  type: rknn
  #  path: //yolov5s_f16.rknn
  #  width: 640
  #  height: 640
  #rknn3:
  #  type: rknn
  #  path: //yolov5s_f16.tflite
    #width: 640
    #height: 640
  coral1:
    type: edgetpu
    device: pci
    #labelmap_path: //labelmap.txt
    #model:
    #  path: //edgetpu_model.tflite
# coral2:
#    type: edgetpu
#    labelmap_path: //labelmap.txt
#    device: pci:1
#    model:
#      path: //edgetpu_model.tflite

#go2rtc:
#  streams:
#    CamStream:
#      - exec:ffmpeg -re -stream_loop -1 -i /config/vid.mp4 -c:v copy -f rtsp -rtsp_transport tcp {{output}}

model:
#  path: //cpu_model.tflite
#  path: //yolov5s_f16.rknn
#  labelmap_path: //labelmap.txt
#  width: 640
#  height: 640
#  width: 320
#  height: 320
#   path: //edgetpu_model.tflite
#  path: //cpu_model.tflite
  path: //edgetpu_model.tflite
  width: 320
  height: 320

#ffmpeg:
#  output_args:
#    record: preset-record-generic-audio-aac
#ffmpeg:
#  hwaccel_args: -hwaccel qsv -qsv_device /dev/dri/renderD128
#  hwaccel_args: -vcodec hevc_rkmpp
#  hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
#  output_args:
#    record: preset-record-generic-audio-aac
#    detect: -f rawvideo -pix_fmt yuv420p -c:a aac
#    rtmp: -c copy -f flv -c:v copy -c:a aac
ffmpeg:
   #hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
  output_args:
    detect: -movflags frag_keyframe+empty_moov -f rawvideo -pix_fmt yuv420p
     #detect: -movflags frag_keyframe+empty_moov -f rawvideo
     #record: -c:v h264_rkmpp_encoder -c:a aac -f segment -strftime 1 -segment_time 60 -segment_format mp4 -reset_timestamps 1
     #record: -c:v copy -c:a aac -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -bsf:v hevc_mp4toannexb 
     #record: -c:v hevc_rkmpp_encoder -c:a aac -f segment -strftime 1 -segment_time 60 -segment_format mp4
     #record: -c:v h264_rkmpp -c:a aac -f segment -strftime 1 -segment_time 60 -segment_format mp4 -reset_timestamps 1
     #record: -c:a aac -c:v copy -map 0 -f segment -strftime 1 -segment_time 60 -segment_format mp4 -reset_timestamps 1
     #rtmp: -c copy -f flv -flvflags no_duration_filesize
   #input_args:
   #  - -avoid_negative_ts
   #  - make_zero
   #hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
  input_args:
  - -avoid_negative_ts
  - make_zero
  - -fflags
  - nobuffer
  - -flags
  - low_delay
  - -strict
  - experimental
  - -analyzeduration
  - 50M
  - -probesize
  - 50M
  - -fflags
  - +genpts+discardcorrupt
    #- -vsync
    #- drop
  - -use_wallclock_as_timestamps
  - '1'

objects:
#  filters:
#    car:
#      mask:
#        - 0,554,692,507,1284,514,1874,555,2560,611,2560,0,0,0
#      min_area: 50000
  track:
  - person
  - dog
  - cat
  - car
  #  - motorcycle
  #- bicycle
  - bus
  #- bird
  filters:
    person:
      min_score: 0.45
      threshold: 0.63
    dog:
      min_score: 0.45
      threshold: 0.6
    cat:
      min_score: 0.45
      threshold: 0.6
    car:
      min_score: 0.5
      threshold: 0.62
  #  motorcycle:
  #    min_score: 0.55
  #    threshold: 0.62
  #  bicycle:
  #    min_score: 0.45
  #    threshold: 0.6
    bus:
      min_score: 0.5
      threshold: 0.62
    #- backpack
    #- handbag
    #- knife
    #- tv
    #- laptop
    #- cell phone

# Optional: birdseye configuration
birdseye:
  # Optional: Enable birdseye view (default: shown below)
  enabled: true
  restream: false
  # Optional: Width of the output resolution (default: shown below)
  width: 1920
  # Optional: Height of the output resolution (default: shown below)
  height: 1080
  # Optional: Encoding quality of the mpeg1 feed (default: shown below)
  # 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
  quality: 15
  # Optional: Mode of the view. Available options are: objects, motion, and continuous
  #   objects - cameras are included if they have had a tracked object within the last 30 seconds
  #   motion - cameras are included if motion was detected in the last 30 seconds
  #   continuous - all cameras are included always
  mode: continuous

cameras:
  camera_three:
    enabled: true
    ffmpeg:
      #hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -c:v hevc_rkmpp_decoder -vcodec hevc_rkmpp_decoder
      #hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -c:v hevc_rkmpp_decoder -vcodec hevc_rkmpp_decoder
      #hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
      hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128
      #hwaccel_args: -c:v hevc_rkmpp_decoder
      #global_args: -hide_banner -loglevel debug
      #global_args: -hide_banner
      inputs:
      - path: 
          rtsp://user:pass@0.0.0.0:554/cam/livecam/realmonitor?channel=1&subtype=0
        input_args: -rtsp_transport tcp -timeout 5000000
        #input_args: -timeout 5000000
        roles:
        - record
    #    - detect
          #  - rtmp
      - path: rtsp://user:pass@0.0.0.0:554/cam/realmonitor?channel=1&subtype=2
        #hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -c:v h264_rkmpp_decoder
        #  input_args: -avoid_negative_ts make_zero -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -timeout 5000000
        roles:
        #    - rtmp
        - detect
      output_args:
        record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -c:v copy -bsf:v hevc_mp4toannexb -c:a copy
        #record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v h264_rkmpp_encoder -c:a aac -b:v 4M
        #record: -f segment -segment_time 10 -segment_format mp4 -strftime 1 --reset_timestamps 1 -c:v hevc_rkmpp_encoder -c:a aac
        #record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:a aac
    #objects:
    #  track:
    #    - person
    #    - dog
    #    - car
    #    - cat
    #    - bicycle
    detect:
      enabled: true
      width: 1920
      height: 1080
      fps: 25
    birdseye:
      order: 4
    snapshots:
      enabled: true
      timestamp: false
    record:
      enabled: true
      events:
        retain:
          default: 10
    rtmp:
      enabled: false
  camera_four:
    enabled: true
    ffmpeg:
      global_args: -hide_banner -loglevel debug
      hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128
      #hwaccel_args: -c:v h264_rkmpp_decoder
      #hwaccel_args: preset-rpi-64-h264
      #hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -c:v h264_rkmpp_decoder -vcodec h264_rkmpp_decoder
  #    hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p
      inputs:
      - path: rtsp://user:pass@0.0.0.0:554/s0
        input_args: preset-rtsp-restream
  #        input_args: -avoid_negative_ts make_zero -flags low_delay -rtsp_transport tcp -timeout 5000000
  #        #input_args: -timeout 5000000
        roles:
        - detect
        - record
  #          - rtmp
  #      - path: rtsp://user:pass@0.0.0.0:554/s0
  #      #  input_args: -avoid_negative_ts make_zero -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -timeout 5000000
  #      #  roles:
  #      #   - rtmp
      output_args:
        record: preset-record-ubiquiti
      #  record: -c:v copy -c:a aac -f segment -strftime 1 -segment_time 60 -segment_format mp4 --reset_timestamps 1
    #objects:
    #  track:
    #    - person
    #    - dog
    #    - car
    #    - cat
    #    - bicycle
    detect:
      enabled: true
      width: 1920
      height: 1080
    #  width: 1280
    #  height: 720
      fps: 30
    birdseye:
      order: 2
    snapshots:
      enabled: true
      timestamp: false
    record:
      enabled: true
      events:
        retain:
          default: 10
    rtmp:
      enabled: false
    motion:
      mask:
      - 1920,1080,1920,473,1859,456,1799,459,1761,476,1677,496,1635,443,1574,367,1507,357,1440,246,1360,257,1313,251,1277,257,1212,298,1168,272,1130,314,988,326,812,493,661,591,326,726,213,1080,373,1080,596,1080,641,1080,669,1080
  camera_one:
    enabled: true
    ffmpeg:
      global_args: -hide_banner -loglevel debug
      #hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -c:v hevc_rkmpp_decoder -vcodec hevc_rkmpp_decoder
      hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128
      #hwaccel_args: -c:v hevc_rkmpp_decoder
      #input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -flags low_delay -rtsp_transport tcp -timeout 5000000
      #input_args: -fflags +genpts+discardcorrupt
      input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -flags low_delay -rtsp_transport tcp -timeout 5000000
      #output_args:
      #  record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:a aac
      #  rtmp: -c:v copy -c:a aac -f flv
  #    hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128
      inputs:
      - path: rtsp://user:pass@0.0.0.0:554/Streaming/Channels/101
        roles:
        - record
      #  - detect
  #          - rtmp
      - path: rtsp://user:pass@0.0.0.0:554/Streaming/Channels/102
        roles:
        - detect
      output_args:
        #detect: -f rawvideo -pix_fmt yuv420p -an
        #record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:v copy -c:a aac
        #record: -c:v copy -c:a aac -f segment -strftime 1 -segment_time 60 -segment_format mp4 -tag:v hvc1 -bsf:v hevc_mp4toannexb --reset_timestamps 1
        #record: -c:v copy -c:a aac -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -bsf:v hevc_mp4toannexb
        #record: -c:v copy -c:a copy -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -bsf:v hevc_mp4toannexb
        #record: -f segment -c:v copy -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:a copy
        #ne radi record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -c:v copy -bsf:v hevc_mp4toannexb -c:a copy
        record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:a aac
        #record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v hevc-rkmpp_encoder -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:a copy
        #- path: rtsp://user:pass@0.0.0.0:554/Streaming/Channels/102/
        #  input_args: -avoid_negative_ts make_zero -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -timeout 5000000 -use_wallclock_as_timestamps 1
        #  roles:
        #    - detect
        #    - rtmp
    rtmp:
      enabled: false
    #objects:
    #  track:
    #    - person
    #    - dog
    #    - car
    #    - cat
    #    - bicycle
    detect:
      enabled: true
      width: 1280
      height: 720
    #  width: 640
    #  height: 360
    #  width: 3840
    #  height: 2160
      fps: 10
    birdseye:
      order: 1
    snapshots:
      enabled: true
      timestamp: false
    record:
      enabled: true
      events:
        retain:
          default: 10
    motion:
      mask:
      - 702,1080,4,1067,0,6,361,0,546,116,511,534,582,737
      - 780,439,899,395,1045,588,1320,1069,665,1080,699,730
      - 1637,1021,1804,881,1920,642,1920,542,1920,502,1920,316,1822,336,1708,408,1715,573,1110,706,1328,1074
  camera_two:
    enabled: true
    ffmpeg:
      global_args: -hide_banner -loglevel error
      #input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -flags low_delay -rtsp_transport tcp -timeout 5000000
      #input_args: -fflags +genpts+discardcorrupt
      input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -flags low_delay -rtsp_transport tcp -timeout 5000000
      #output_args:
      #  record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:a aac
      #  rtmp: -c:v copy -c:a aac -f flv
      #hwaccel_rgs: -hwaccel drm -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -c:v hevc_rkmpp_decoder -vcodec hevc_rkmpp_decoder
      hwaccel_args: -hwaccel drm -hwaccel_device /dev/dri/renderD128
      #hwaccel_args: -c:v hevc_rkmpp_decoder
      inputs:
      - path: rtsp://user:pass@0.0.0.0:554/Streaming/Channels/101
          #input_args: -rtsp_transport tcp -timeout 5000000
          #input_args: -timeout 5000000
        roles:
          # rtmp
        - record
      #  - detect
      - path: rtsp://user:pass@0.0.0.0:554/Streaming/Channels/102
        roles:
        - detect
      output_args:
        #detect: -f rawvideo -pix_fmt yuv420p -an
        #record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:a copy
        #ne radi record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -c:v copy -bsf:v hevc_mp4toannexb -c:a copy
        record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -tag:v hvc1 -bsf:v hevc_mp4toannexb -c:a aac
        #record: -c:v copy -c:a aac -f segment -strftime 1 -segment_time 60 -segment_format mp4 -tag:v hvc1 -bsf:v hevc_mp4toannexb --reset_timestamps 1
        #record: -c:v copy -c:a aac -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -bsf:v hevc_mp4toannexb
        #record: -c:v copy -c:a aac -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -tag:v hvc1 -bsf:v hevc_mp4toannexb
        #record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v h264_rkmpp_encoder -c:a aac -b:v 4M
        #- path: rtsp://user:pass@0.0.0.0:554/Streaming/Channels/102/
        #  input_args: -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1
        #  roles:
        #    - detect
    #objects:
    #  track:
    #    - person
    #    - dog
    #    - car
    #    - cat
    #    - bicycle
    rtmp:
      enabled: false
    detect:
      enabled: false
    #  width: 3840
    #  height: 2160
      width: 640
      height: 360
    #  width: 3840
    #  height: 2160
      fps: 10
    #  fps: 12
    birdseye:
      order: 3
    snapshots:
      enabled: true
      timestamp: false
    record:
      enabled: true
      events:
        retain:
          default: 10
    motion:
      mask:
      - 406,626,590,826,712,899,765,1007,804,1080,1285,1080,1920,1080,1879,901,1891,756,1920,0,847,0,397,569
ui:
  timezone: Europe/Berlin
```


### Relevant log output

```shell
2023-12-08 15:00:39.611350421  [2023-12-08 15:00:39] frigate.output                 WARNING : Unable to copy frame camera_one1702043799.862441 to birdseye.
2023-12-08 15:00:39.632259909  [2023-12-08 15:00:39] frigate.output                 WARNING : Unable to copy frame camera_two1702043799.847388 to birdseye.
2023-12-08 15:00:39.635815210  [2023-12-08 15:00:39] frigate.output                 WARNING : Unable to copy frame camera_three1702043799.982404 to birdseye.
2023-12-08 15:00:39.714655398  [2023-12-08 15:00:39] frigate.output                 WARNING : Unable to copy frame camera_one1702043799.862441 to birdseye.
2023-12-08 15:04:01.764296398  [2023-12-08 15:04:01] watchdog.camera_two  INFO    : Terminating the existing ffmpeg process...
2023-12-08 15:04:01.802510781  [2023-12-08 15:04:01] watchdog.camera_two  INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 15:06:11.854848951  [2023-12-08 15:06:11] watchdog.camera_two  INFO    : Terminating the existing ffmpeg process...
2023-12-08 15:06:11.894444247  [2023-12-08 15:06:11] watchdog.camera_two  INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 15:06:21.931313359  [2023-12-08 15:06:21] watchdog.camera_two  INFO    : Terminating the existing ffmpeg process...
2023-12-08 15:06:21.944474390  [2023-12-08 15:06:21] watchdog.camera_two  INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 15:06:26.089403746  [ERROR:0@1096.732] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
2023-12-08 15:06:26.089411329  
2023-12-08 15:06:26.089413662  OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern'
2023-12-08 15:06:26.089419496  
2023-12-08 15:06:26.089420371  
2023-12-08 15:06:31.984199658  [2023-12-08 15:06:31] watchdog.camera_two  INFO    : Terminating the existing ffmpeg process...
2023-12-08 15:06:31.984215699  [2023-12-08 15:06:31] watchdog.camera_two  INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 15:06:42.007579789  [2023-12-08 15:06:42] watchdog.camera_two  INFO    : Terminating the existing ffmpeg process...
2023-12-08 15:06:42.024859603  [2023-12-08 15:06:42] watchdog.camera_two  INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 15:06:46.092608049  [ERROR:0@1116.735] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
2023-12-08 15:06:46.092614174  
2023-12-08 15:06:46.092616215  OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern'
2023-12-08 15:06:46.092617090  
2023-12-08 15:06:46.092617673  
2023-12-08 15:06:51.088392047  [ERROR:0@1121.731] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
2023-12-08 15:06:51.088401380  
2023-12-08 15:06:51.088403422  OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern'
2023-12-08 15:06:51.088404880  
2023-12-08 15:06:51.088405463  
2023-12-08 15:06:52.054784645  [2023-12-08 15:06:52] watchdog.camera_two  INFO    : Terminating the existing ffmpeg process...
2023-12-08 15:06:52.057636760  [2023-12-08 15:06:52] watchdog.camera_two  INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 15:08:42.150142279  [2023-12-08 15:08:42] watchdog.camera_two  INFO    : Terminating the existing ffmpeg process...
2023-12-08 15:08:42.150637513  [2023-12-08 15:08:42] watchdog.camera_two  INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 15:08:52.215560609  [2023-12-08 15:08:52] watchdog.camera_two  INFO    : Terminating the existing ffmpeg process...
2023-12-08 15:08:52.217216056  [2023-12-08 15:08:52] watchdog.camera_two  INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 15:08:56.090572853  [ERROR:0@1246.733] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
2023-12-08 15:08:56.090578395  
2023-12-08 15:08:56.090581020  OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern'
2023-12-08 15:08:56.090582186  
2023-12-08 15:08:56.090583061  
2023-12-08 15:08:56.117233237  [ERROR:0@1246.759] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
2023-12-08 15:08:56.117237612  
2023-12-08 15:08:56.117239653  OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern'
2023-12-08 15:08:56.117240528  
2023-12-08 15:08:56.117241112  
2023-12-08 15:08:56.261894328  [2023-12-08 15:08:56] frigate.record.maintainer      ERROR   : Error occurred when attempting to maintain recording cache
2023-12-08 15:08:56.263111121  [2023-12-08 15:08:56] frigate.record.maintainer      ERROR   : could not convert string to float: 'N/A'
```


### FFprobe output from your camera

```shell
[{"return_code":0,"stderr":"","stdout":{"programs":[],"streams":[{"avg_frame_rate":"12/1","codec_long_name":"H.265/HEVC(HighEfficiencyVideoCoding)","display_aspect_ratio":"168:95","height":1520,"width":2688},{"avg_frame_rate":"0/0","codec_long_name":"AAC(AdvancedAudioCoding)"}]}},{"return_code":0,"stderr":"","stdout":{"programs":[],"streams":[{"avg_frame_rate":"10/1","codec_long_name":"H.265/HEVC(HighEfficiencyVideoCoding)","display_aspect_ratio":"16:9","height":360,"width":640}]}}]
```


### Frigate stats

_No response_

### Operating system

Debian

### Install method

Docker Compose

### Coral version

M.2

### Network connection

Wired

### Camera make and model

dahua

### Any other information that may be helpful

_No response_


Discussion:
Opencv is just logging that the recording data is bad and ffmpeg has crashed due to bad data as well. It would be good to see a full copy of the logs 
this just keeps repeating with the frigate.record.maintainer

```
2023-12-08 15:09:11.272205132  [2023-12-08 15:09:11] frigate.record.maintainer      ERROR   : Error occurred when attempting to maintain recording cache
2023-12-08 15:09:11.272691324  [2023-12-08 15:09:11] frigate.record.maintainer      ERROR   : could not convert string to float: 'N/A'
2023-12-08 15:09:12.320451984  [2023-12-08 15:09:12] watchdog.camera_twoINFO    : Terminating the existing ffmpeg process...
2023-12-08 15:09:12.320773390  [2023-12-08 15:09:12] watchdog.camera_two  INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 15:09:16.103754790  [ERROR:0@1266.746] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
2023-12-08 15:09:16.103766457  
2023-12-08 15:09:16.103771415  OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern'
2023-12-08 15:09:16.103773165  
2023-12-08 15:09:16.103774915  
2023-12-08 15:09:16.323699601  [2023-12-08 15:09:16] frigate.record.maintainer      ERROR   : Error occurred when attempting to maintain recording cache
2023-12-08 15:09:16.324114921  [2023-12-08 15:09:16] frigate.record.maintainer      ERROR   : could not convert string to float: 'N/A'
2023-12-08 15:09:16.602782199  [2023-12-08 15:09:16] asyncio                        WARNING : Loop <_UnixSelectorEventLoop running=False closed=True debug=False> that handles pid 6013 is closed
2023-12-08 15:09:21.075812674  Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x7f9d426e50>
2023-12-08 15:09:21.075817924  Traceback (most recent call last):
2023-12-08 15:09:21.075842132    File "/usr/lib/python3.9/asyncio/base_subprocess.py", line 126, in __del__
2023-12-08 15:09:21.076826475      self.close()
2023-12-08 15:09:21.076832016    File "/usr/lib/python3.9/asyncio/base_subprocess.py", line 104, in close
2023-12-08 15:09:21.076833183      proto.pipe.close()
2023-12-08 15:09:21.076834641    File "/usr/lib/python3.9/asyncio/unix_events.py", line 536, in close
2023-12-08 15:09:21.076996511      self._close(None)
2023-12-08 15:09:21.077000011    File "/usr/lib/python3.9/asyncio/unix_events.py", line 560, in _close
2023-12-08 15:09:21.077139423      self._loop.call_soon(self._call_connection_lost, exc)
2023-12-08 15:09:21.077252878    File "/usr/lib/python3.9/asyncio/base_events.py", line 751, in call_soon
2023-12-08 15:09:21.077381207      self._check_closed()
2023-12-08 15:09:21.077383540    File "/usr/lib/python3.9/asyncio/base_events.py", line 515, in _check_closed
2023-12-08 15:09:21.077524119      raise RuntimeError('Event loop is closed')
2023-12-08 15:09:21.077559409  RuntimeError: Event loop is closed
```
That's more helpful, very weird 
After restart everything works as expected for 5 minutes or 3 hours. After that, no clips are recorded and I need to restart again.

```
2023-12-11 07:48:24.019420470  [2023-12-11 07:48:24] frigate.record.maintainer      ERROR   : Error occurred when attempting to maintain recording cache
2023-12-11 07:48:24.019861747  [2023-12-11 07:48:24] frigate.record.maintainer      ERROR   : could not convert string to float: 'N/A'
......
2023-12-11 09:22:56.872708540  [ERROR:0@11.647] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
2023-12-11 09:22:56.872713206  
2023-12-11 09:22:56.872715540  OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern'
```
this repeats contantly.

Resolving patch:
diff --git a/frigate/util/services.py b/frigate/util/services.py
--- a/frigate/util/services.py
+++ b/frigate/util/services.py
@@ -371,7 +371,7 @@ def vainfo_hwaccel(device_name: Optional[str] = None) -> sp.CompletedProcess:
     return sp.run(ffprobe_cmd, capture_output=True)
 
 
-async def get_video_properties(url, get_duration=False):
+async def get_video_properties(url, get_duration=False) -> dict[str, any]:
     async def calculate_duration(video: Optional[any]) -> float:
         duration = None
 
@@ -405,7 +405,10 @@ async def calculate_duration(video: Optional[any]) -> float:
                 result = None
 
             if result:
-                duration = float(result.strip())
+                try:
+                    duration = float(result.strip())
+                except ValueError:
+                    duration = -1
             else:
                 duration = -1
 


Test patch: