frigate: [Support]: 0.11.0 Beta/RC - Unable to get sound working from Unifi Cameras sourced from Unifi Protect

Describe the problem you are having

Frigate 0.11.0 Beta 2 is not able to record

Version

0.11.0-D2C3CDC

Frigate config file

---
logger:
  default: info
  logs:
    frigate.record: debug

mqtt:
  host: emqx
  topic_prefix: frigate
  user: mqtt
  password: "{FRIGATE_MQTT_PASSWORD}"

database:
  path: /data/frigate.db

detectors:
  coral:
    type: edgetpu
    device: usb

objects:
  track:
    - person
  filters:
    person:
      min_area: 2500
      max_area: 100000
      threshold: 0.7

ffmpeg:
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p
  # Enable audio on recordings
  output_args:
    record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -c:a aac

rtmp:
  enabled: true

snapshots:
  enabled: true
  timestamp: false
  bounding_box: true
  retain:
    default: 7

record:
  enabled: true
  retain:
    days: 3
    mode: all
  events:
    retain:
      default: 7
      mode: active_objects

cameras:
  frigate_river:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.2:7447/GtBsJuujvMQwA42n
          roles:
            - detect
        - path: rtsp://192.168.1.2:7447/b2K0uh13iekTbyA1
          roles:
            - rtmp
            - record
    detect:
      width: 1024
      height: 576
      fps: 10

  frigate_driveway:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.2:7447/Bbu0H4JuPjzK6zy9
          roles:
            - detect
        - path: rtsp://192.168.1.2:7447/vixHJ1htwDadpDgE
          roles:
            - rtmp
            - record
    detect:
      width: 1280
      height: 720
      fps: 10

  frigate_garage:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.2:7447/3mzDU0htPbIcPPFH
          roles:
            - detect
        - path: rtsp://192.168.1.2:7447/Cpb9YqiSgX16LjsX
          roles:
            - rtmp
            - record
    detect:
      width: 1024
      height: 576
      fps: 10

  frigate_living_room:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.2:7447/PgTHLlRmqRH6Z6wV
          roles:
            - detect
        - path: rtsp://192.168.1.2:7447/dGFODTTigTod247N
          roles:
            - rtmp
            - record
    detect:
      width: 1024
      height: 576
      fps: 10

  frigate_basement_2:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.2:7447/pp1jGiFpb1AuVHRl
          roles:
            - detect
        - path: rtsp://192.168.1.2:7447/z6XEPgL62FAvtpPR
          roles:
            - rtmp
            - record
    detect:
      width: 1024
      height: 576
      fps: 10

Relevant log output

frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : [rtsp @ 0x5607230ba200] DTS discontinuity in stream 1: packet 8 with DTS 79400665118269, packet 9 with DTS 79400665120654
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : [rtsp @ 0x5607230ba200] DTS discontinuity in stream 1: packet 29 with DTS 79400665136112, packet 30 with DTS 79400665143396
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : [rtsp @ 0x5607230ba200] DTS discontinuity in stream 0: packet 34 with DTS 79400665145328, packet 35 with DTS 79400665149145
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : [rtsp @ 0x5607230ba200] DTS discontinuity in stream 0: packet 43 with DTS 79400665152993, packet 44 with DTS 79400665156793
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : [rtsp @ 0x5607230ba200] DTS discontinuity in stream 1: packet 55 with DTS 79400665162605, packet 56 with DTS 79400665164678
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : [rtsp @ 0x5607230ba200] DTS discontinuity in stream 1: packet 57 with DTS 79400665164680, packet 58 with DTS 79400665168356
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : [rtsp @ 0x5607230ba200] DTS discontinuity in stream 1: packet 59 with DTS 79400665168357, packet 60 with DTS 79400665172218
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : [flv @ 0x5607230e2900] FLV does not support sample rate 48000, choose from (44100, 22050, 11025)
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : [flv @ 0x5607230e2900] Audio codec opus not compatible with flv
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : Could not write header for output file #1 (incorrect codec parameters ?): Function not implemented
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   : Error initializing output stream 1:1 --
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_basement_2.record_rtmp ERROR   :
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] watchdog.frigate_basement_2    INFO    : Terminating the existing ffmpeg process...
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] watchdog.frigate_basement_2    INFO    : Waiting for ffmpeg to exit gracefully...
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : [rtsp @ 0x564e3e086200] DTS discontinuity in stream 1: packet 6 with DTS 79400665147812, packet 7 with DTS 79400665151007
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : [rtsp @ 0x564e3e086200] DTS discontinuity in stream 1: packet 10 with DTS 79400665151012, packet 11 with DTS 79400665157414
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : [rtsp @ 0x564e3e086200] DTS discontinuity in stream 1: packet 15 with DTS 79400665157418, packet 16 with DTS 79400665160637
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : [rtsp @ 0x564e3e086200] DTS discontinuity in stream 1: packet 19 with DTS 79400665160641, packet 20 with DTS 79400665166151
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : [rtsp @ 0x564e3e086200] DTS discontinuity in stream 1: packet 24 with DTS 79400665166155, packet 25 with DTS 79400665170289
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : [rtsp @ 0x564e3e086200] DTS discontinuity in stream 1: packet 29 with DTS 79400665170296, packet 30 with DTS 79400665173475
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : [rtsp @ 0x564e3e086200] DTS discontinuity in stream 1: packet 33 with DTS 79400665173482, packet 34 with DTS 79400665179861
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : [flv @ 0x564e3e109dc0] FLV does not support sample rate 48000, choose from (44100, 22050, 11025)
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : [flv @ 0x564e3e109dc0] Audio codec opus not compatible with flv
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : Could not write header for output file #1 (incorrect codec parameters ?): Function not implemented
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   : Error initializing output stream 1:1 --
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_garage.record_rtmp ERROR   :
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] watchdog.frigate_garage        INFO    : Terminating the existing ffmpeg process...
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] watchdog.frigate_garage        INFO    : Waiting for ffmpeg to exit gracefully...
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   : [rtsp @ 0x55a234464200] DTS discontinuity in stream 1: packet 3 with DTS 79400665116228, packet 4 with DTS 79400665123795
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   : [rtsp @ 0x55a234464200] DTS discontinuity in stream 1: packet 24 with DTS 79400665133337, packet 25 with DTS 79400665137364
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   : [rtsp @ 0x55a234464200] DTS discontinuity in stream 1: packet 29 with DTS 79400665137367, packet 30 with DTS 79400665141422
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   : [rtsp @ 0x55a234464200] DTS discontinuity in stream 1: packet 33 with DTS 79400665141427, packet 34 with DTS 79400665147373
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   : [rtsp @ 0x55a234464200] DTS discontinuity in stream 1: packet 37 with DTS 79400665147381, packet 38 with DTS 79400665151356
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   : [flv @ 0x55a23448c900] FLV does not support sample rate 48000, choose from (44100, 22050, 11025)
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   : [flv @ 0x55a23448c900] Audio codec opus not compatible with flv
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   : Could not write header for output file #1 (incorrect codec parameters ?): Function not implemented
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   : Error initializing output stream 1:1 --
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] ffmpeg.frigate_driveway.record_rtmp ERROR   :
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] watchdog.frigate_driveway      INFO    : Terminating the existing ffmpeg process...
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:33] watchdog.frigate_driveway      INFO    : Waiting for ffmpeg to exit gracefully...
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:37] frigate.record                 WARNING : Discarding a corrupt recording segment: frigate_river-20220602103533.mp4
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:37] frigate.record                 WARNING : Discarding a corrupt recording segment: frigate_river-20220602103533.mp4
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:37] frigate.record                 WARNING : Discarding a corrupt recording segment: frigate_river-20220602103533.mp4
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:37] frigate.record                 WARNING : Discarding a corrupt recording segment: frigate_river-20220602103533.mp4
frigate-6d45776766-7lw4d frigate [2022-06-02 10:35:37] frigate.record                 WARNING : Discarding a corrupt recording segment: frigate_river-20220602103533.mp4

FFprobe output from your camera

✖ ffprobe rtsp://192.168.1.2:7447/pp1jGiFpb1AuVHRl
ffprobe version 5.0.1 Copyright (c) 2007-2022 the FFmpeg developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/5.0.1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Input #0, rtsp, from 'rtsp://192.168.1.2:7447/pp1jGiFpb1AuVHRl':
  Metadata:
    title           : FCECDA1FC058_1
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Audio: aac (LC), 48000 Hz, mono, fltp
  Stream #0:1: Audio: opus, 48000 Hz, stereo, fltp
  Stream #0:2: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1024x576 [SAR 1:1 DAR 16:9], 15 fps, 25 tbr, 90k tbn

Frigate stats

{"detection_fps":7.2,"detectors":{"coral":{"detection_start":1654180918.187599,"inference_speed":22.52,"pid":223}},"frigate_basement_2":{"camera_fps":10.1,"capture_pid":265,"detection_fps":0.0,"pid":243,"process_fps":10.1,"skipped_fps":0.0},"frigate_driveway":{"camera_fps":10.1,"capture_pid":249,"detection_fps":6.0,"pid":236,"process_fps":8.9,"skipped_fps":0.0},"frigate_garage":{"camera_fps":10.1,"capture_pid":255,"detection_fps":0.0,"pid":238,"process_fps":10.1,"skipped_fps":0.0},"frigate_living_room":{"camera_fps":10.1,"capture_pid":260,"detection_fps":1.2,"pid":241,"process_fps":10.0,"skipped_fps":0.0},"frigate_river":{"camera_fps":10.0,"capture_pid":245,"detection_fps":0.0,"pid":234,"process_fps":10.0,"skipped_fps":0.0},"service":{"latest_version":"0.10.1","storage":{"/dev/shm":{"free":4286.8,"mount_type":"tmpfs","total":4295.0,"used":8.1},"/media/frigate/clips":{"free":63103404.3,"mount_type":"nfs4","total":63111443.8,"used":8039.4},"/media/frigate/recordings":{"free":63103404.3,"mount_type":"nfs4","total":63111443.8,"used":8039.4},"/tmp/cache":{"free":136834.0,"mount_type":"overlay","total":244528.6,"used":95201.8}},"temperatures":{},"uptime":57223,"version":"0.11.0-d2c3cdc"}}

Operating system

Other

Install method

Kubernetes

Coral version

USB

Network connection

Wired

Camera make and model

Unifi Protect Cameras

G3 Flex G4 Pro G3 Bullet G3 Instant

Any other information that may be helpful

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 32 (8 by maintainers)

Most upvoted comments

I also faced this issue. And here’s what worked for me so far. Audio is working as it was. And there’s no significant increase in my resource usage.

I think the idea here is to convert the audio format and sampling rate. I’m not sure about the details, I just did many trials and errors. I’m on unifi protect 2.1.2, and the camera is g4 doorbell

camera_3:
  ffmpeg:
    output_args:
      record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v copy -ar 44100 -c:a aac
      rtmp: -c:v copy -f flv -ar 44100 -c:a aac
    inputs:
      - path: rtsps://172.19.20.1:7441/xxx?enableSrtp
        roles:
          - record
      - path: rtsps://172.19.20.1:7441/xxx?enableSrtp
        roles:
          - detect
          - rtmp

Ran into this issue yesterday, I found another solution, or cause to the problem The stream from unifi cameras seems to include two audio tracks, one AAC and one Opus, so instead of re-encode the stream, I mapped the correct one as follows:

record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -map 0:v:0 -map 0:a:0 -c copy

Didn’t try rtmp as I’m not using it, hope it’s helpful for someone

RTMP is used for the camera entity stream in home assistant. Many users use the frigate-hass-card which can use the frigate jsmpeg stream instead and RTMP can be disabled so figured I’d ask.

but would be nice if frigate / ffmpeg could support 48000Hz

would have to see if this is on ffmpeg specifically or something frigate can do about it, seems in general an issue ubiquiti should address / give options for

but would be nice if frigate / ffmpeg could re-sample the audio

that should already be doable using input args (assuming ffmpeg supports it). Maybe try just using the same args in addition with -q:a # per https://stackoverflow.com/questions/67880409/ffmpeg-how-to-resample-audio-file

Yep, no problem. Sorry I was delayed on this. I never got notified on Github 😦

Thanks, I wanted to wait for confirmation from you since you were the author. I will make a PR to add this to the camera-specific section

Just to follow up on this, I removed audio and had zero issues. I then added it back and actually had issues with all the cameras coming back on. Looking at the docker logs it appears ffmpeg was crashing periodically for all the cameras and would keep getting restarted. I thinking this had to be happening yesterday as well and I just didn’t notice it. Not exactly sure on the cause, but have playing around a bit and having no luck I went back to just using the streams without the audio (-an). Still curious if @iqbalaydrus is having success with v0.11 or v0.10 versions of frigate.

Also when I first went to v0.11rc1 it was being sluggish but after applying the environment variable “LIBVA_DRIVER_NAME_JELLYFIN=i965” it seemed to work like it used to on v0.10.

Perfect that’s what I was going to suggest, the older driver needs to be forced. That should be a solid setup again, glad to hear audio is working as well