blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
18.11k stars 1.65k forks source link

Recorded videos always judder #1799

Closed fbcd4f50ea5350f051450323b5abfd0b closed 2 years ago

fbcd4f50ea5350f051450323b5abfd0b commented 2 years ago

Describe the bug Frigate itself works great, but all of my recorded videos are juddery. No matter if I play them in the browser or directly the files with VLC or Quicktime. They always run smoothly for 1-2 seconds, then they stall again.

Do I still have an error somewhere in the configuration?

Version of frigate 0.9.0-7b063a1 (same issue with 0.8.4)

Config file

logger:
  default: info
  # logs:
  #   frigate.events: debug

detectors:
  coral1:
    type: edgetpu
    device: pci:0

mqtt:
  host: REMOVED
  topic_prefix: frigate
  client_id: frigate
  user: REMOVED
  password: REMOVED
  stats_interval: 600

ffmpeg:
  input_args:
    - -avoid_negative_ts
    - make_zero
    - -fflags
    - nobuffer
    - -flags
    - low_delay
    - -strict
    - experimental
    - -fflags
    - +genpts+discardcorrupt
    - -rw_timeout
    - "5000000"
    - -use_wallclock_as_timestamps
    - "1"
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128

detect:
  enabled: True
  width: 2560
  height: 1440
  fps: 5
  max_disappeared: 100

objects:
  track:
    - person
    - car
    - motorcycle
    - bicycle
    - cat
    - dog

record:
  enabled: True
  retain_days: 2
  events:
    pre_capture: 5
    post_capture: 5
    objects:
      - person
      - car
      - motorcycle
      - bicycle
      - cat
      - dog
    retain:
      default: 14

snapshots:
  enabled: True
  timestamp: True
  bounding_box: False
  retain:
    default: 14

rtmp:
  enabled: False

timestamp_style:
  position: "tl"
  format: "%d.%m.%Y %H:%M:%S"
  thickness: 1

cameras:
  carport:
    ffmpeg:
      inputs:
        - path: rtmp://[...]
          roles:
            - detect
            - record
    best_image_timeout: 240

    mqtt:
      enabled: True
      timestamp: True
      bounding_box: False
      crop: True
      height: 360

    objects:
      filters:
        car:
          mask:
            - 811,1147,1062,912,1138,844,1496,712,1448,425,1671,158,2560,87,2560,1440,722,1440

  entrance:
    ffmpeg:
      inputs:
        - path: rtmp://[...]
          roles:
            - detect
            - record
    best_image_timeout: 240

    mqtt:
      enabled: True
      timestamp: True
      bounding_box: False
      crop: True
      height: 360

    motion:
      mask:
        - 1562,0,2560,0,2560,1440,1909,1440
        - 0,1440,0,0,518,0,647,860,996,936,1060,1440

  frontdoor:
    ffmpeg:
      inputs:
        - path: rtmp://[...]
          roles:
            - detect
            - record
    best_image_timeout: 240

    mqtt:
      enabled: True
      timestamp: True
      bounding_box: False
      crop: True
      height: 360

    motion:
      mask:
        - 1946,0,2560,0,2560,1440,1760,1440
        - 0,0,844,0,970,1440,0,1440

Frigate container logs

nothing relevant

Frigate stats

{"carport":{"camera_fps":5.1,"capture_pid":232,"detection_fps":0.0,"pid":223,"process_fps":5.1,"skipped_fps":0.0},"detection_fps":5.1,"detectors":{"coral1":{"detection_start":0.0,"inference_speed":7.82,"pid":217}},"entrance":{"camera_fps":5.1,"capture_pid":243,"detection_fps":5.1,"pid":227,"process_fps":5.1,"skipped_fps":0.0},"frontdoor":{"camera_fps":5.1,"capture_pid":246,"detection_fps":0.0,"pid":230,"process_fps":5.1,"skipped_fps":0.0},"service":{"storage":{"/dev/shm":{"free":116.2,"mount_type":"tmpfs","total":134.2,"used":18.0},"/media/frigate/clips":{"free":1674788.1,"mount_type":"btrfs","total":2000397.9,"used":324507.1},"/media/frigate/recordings":{"free":1674788.1,"mount_type":"btrfs","total":2000397.9,"used":324507.1},"/tmp/cache":{"free":940.4,"mount_type":"tmpfs","total":1000.0,"used":59.6}},"uptime":94387,"version":"0.9.0-7b063a1"}}

FFprobe from your camera

Run the following command and paste output below

ffprobe version 4.3.1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libfreetype --enable-libvidstab --enable-libmfx --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-vaapi --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, flv, from 'rtmp://REMOVED/bcs/channel0_main.bcs?channel=0&stream=0&user=REMOVED&password=REMOVED':
  Metadata:
    displayWidth    : 2560
    displayHeight   : 1440
  Duration: 00:00:00.00, start: 572054.855000, bitrate: N/A
    Stream #0:0: Data: none
    Stream #0:1: Video: h264, yuv420p(progressive), 2560x1440, 5 fps, 6 tbr, 1k tbn
    Stream #0:2: Audio: aac, 16000 Hz, mono, fltp
Unsupported codec with id 0 for input stream 0

Computer Hardware

Camera Info:

Additional context Video example: https://www.dropbox.com/s/hc5jmu9hdbj5hkh/clip_children.mov?dl=0

Thank you so much for this awesome piece of software and the possibility to get support here!

blakeblackshear commented 2 years ago

Try the updated recommendation for Reolink cameras

https://github.com/blakeblackshear/frigate/blob/release-0.9.0/docs/docs/configuration/camera_specific.md#rtmp-cameras-reolink-410520-and-possibly-others

fbcd4f50ea5350f051450323b5abfd0b commented 2 years ago

I added

ffmpeg:
  input_args:
    - -f 
    - live_flv

and it's a lot better now. Not perfect, but a lot better.

Thank you for your help!

blakeblackshear commented 2 years ago

Note that this replaces all the default input args, it doesn't add them the the defaults. You may want to incorporate the defaults too.

fbcd4f50ea5350f051450323b5abfd0b commented 2 years ago

Sorry, that was misleading from me. The config now looks like this:

ffmpeg:
  input_args:
    - -avoid_negative_ts
    - make_zero
    - -fflags
    - nobuffer
    - -flags
    - low_delay
    - -strict
    - experimental
    - -fflags
    - +genpts+discardcorrupt
    - -rw_timeout
    - "5000000"
    - -use_wallclock_as_timestamps
    - "1"
    - -f 
    - live_flv
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
sandstormkeshav commented 2 years ago

@fbcd4f50ea5350f051450323b5abfd0b Did adding all the other options make your recordings smooth?

fbcd4f50ea5350f051450323b5abfd0b commented 2 years ago

With these options they're pretty smooth. Not perfect but a lot better.

sandstormkeshav commented 2 years ago

With these options they're pretty smooth. Not perfect but a lot better.

I see that those options don't have the live_flv flag in there, did adding that make any difference for you. I seem to have stutters about every 2 seconds when viewing the recordings.

fbcd4f50ea5350f051450323b5abfd0b commented 2 years ago

I see that those options don't have the live_flv flag in there, did adding that make any difference for you.

Yes, less stutters. However, the new configuration seems to be even better.

sandstormkeshav commented 2 years ago

I see that those options don't have the live_flv flag in there, did adding that make any difference for you.

Yes, less stutters. However, the new configuration seems to be even better.

Thank You! Now just need to figure out how to get this working in rpisurv as well!