question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Support]: Beta2 FFmpeg QSV HW Acceleration and audio not working on Reolink Cams

See original GitHub issue

Describe the problem you are having

Green screens and errors (with Reolink cameras) if using FFmpeg hwaccel_args for QSV, plus previous detect and record args also throw errors.

Intel 11th Gen NUC running Clear Linux + Docker.

This FFmpeg config works without errors:

ffmpeg:
  # hwaccel_args: -hwaccel_output_format qsv -c:v h264_qsv
  input_args: -avoid_negative_ts make_zero -fflags nobuffer+genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000
  # output_args:
    # detect: -f rawvideo -vf hwdownload,format=nv12 -pix_fmt yuv420p
    # record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy # -an

EDIT: note - hwaccel qsv has been deprecated according to logged output, thus my new argument in config.

[2022-05-19 11:01:12] ffmpeg.Driveway.record         ERROR   : WARNING: defaulting hwaccel_output_format to qsv for compatibility with old commandlines. This behaviour is DEPRECATED and will be removed in the future. Please explicitly set "-hwaccel_output_format qsv".

(Trying to find the new record args to get audio now…)

Version

0.11.0-D2C3CDC

Frigate config file

database:
  path: /db/frigate.db

mqtt:
  host: 192.168.1.5
  port: 1883
  user: mqtt
  password: "{FRIGATE_MQTT_PASSWORD}"

birdseye:
  mode: continuous
  width: 1792
  height: 1344

detect:
  width: 896
  height: 672
  fps: 5
  stationary:
    interval: 10

detectors:
  coral:
    type: edgetpu
    device: usb

ffmpeg:
  hwaccel_args: -hwaccel_output_format qsv -c:v h264_qsv
  input_args: -avoid_negative_ts make_zero -fflags nobuffer+genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000
  output_args:
    detect: -f rawvideo -vf hwdownload,format=nv12 -pix_fmt yuv420p
    record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy # -an

live:
  height: 672

motion:
  mask:
    - 265,650,265,625,630,625,630,650

objects:
  filters:
    person:
      min_area: 5000
      min_score: 0.6

record:
  enabled: True
  expire_interval: 240
  retain:
    days: 5
    mode: motion
  events:
    retain:
      default: 21
      mode: active_objects

rtmp:
  enabled: False

snapshots:
  enabled: True
  clean_copy: False
  bounding_box: True
  retain:
    default: 60

timestamp_style:
  format: "%d/%m/%Y %H:%M:%S"

cameras:
  Balcony:
    ffmpeg:
      inputs:
        - path: http://192.168.1.76/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user={FRIGATE_USER}&password={FRIGATE_PASSWORD}
          roles:
            - detect
        - path: http://192.168.1.76/flv?port=1935&app=bcs&stream=channel0_main.bcs&user={FRIGATE_USER}&password={FRIGATE_PASSWORD}
          roles:
            - record
    objects:
      track:
        - person
        - vehicle

Relevant log output

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[2022-05-19 11:33:05] frigate.app                    INFO    : Starting Frigate (0.11.0-d2c3cdc)
Starting migrations
[2022-05-19 11:33:05] peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
[2022-05-19 11:33:05] peewee_migrate                 INFO    : There is nothing to migrate
[2022-05-19 11:33:05] detector.coral                 INFO    : Starting detection process: 223
[2022-05-19 11:33:05] frigate.app                    INFO    : Output process started: 225
[2022-05-19 11:33:05] frigate.edgetpu                INFO    : Attempting to load TPU as usb
[2022-05-19 11:33:05] ws4py                          INFO    : Using epoll
[2022-05-19 11:33:05] frigate.app                    INFO    : Camera processor started for Balcony: 231
[2022-05-19 11:33:07] frigate.edgetpu                INFO    : TPU found
[2022-05-19 11:33:05] frigate.app                    INFO    : Capture process started for Balcony: 234
[2022-05-19 11:33:05] ws4py                          INFO    : Using epoll
[2022-05-19 11:33:25] watchdog.Balcony               INFO    : No frames received from Balcony in 20 seconds. Exiting ffmpeg...
[2022-05-19 11:33:25] watchdog.Balcony               INFO    : Waiting for ffmpeg to exit gracefully...
[2022-05-19 11:33:25] frigate.video                  ERROR   : Balcony: Unable to read frames from ffmpeg process.
[2022-05-19 11:33:25] frigate.video                  ERROR   : Balcony: ffmpeg process is not running. exiting capture thread...
[2022-05-19 11:33:25] ffmpeg.Balcony.record          ERROR   : [mp4 @ 0x56024f797340] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 31200 >= 224
[2022-05-19 11:33:25] ffmpeg.Balcony.record          ERROR   : av_interleaved_write_frame(): Invalid argument
[2022-05-19 11:33:25] watchdog.Balcony               INFO    : Terminating the existing ffmpeg process...
[2022-05-19 11:33:25] watchdog.Balcony               INFO    : Waiting for ffmpeg to exit gracefully...
[2022-05-19 11:33:35] watchdog.Balcony               ERROR   : Ffmpeg process crashed unexpectedly for Balcony.
[2022-05-19 11:33:35] watchdog.Balcony               ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : Error while decoding stream #0:0: Invalid argument
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : [h264_qsv @ 0x55bd5c6bec40] Error initializing the MFX video decoder: invalid video parameters (-15)
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : Error while decoding stream #0:0: Invalid argument
...
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : [h264_qsv @ 0x55bd5c6bec40] [IMGUTILS @ 0x7ffd71561e90] Picture size 0x0 is invalid
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : [h264_qsv @ 0x55bd5c6bec40] video_get_buffer: image parameters invalid
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : [h264_qsv @ 0x55bd5c6bec40] get_buffer() failed
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : Error while decoding stream #0:0: Invalid argument
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : Finishing stream 0:0 without any data written to it.
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scaler_0'
[2022-05-19 11:33:35] ffmpeg.Balcony.detect          ERROR   : Error configuring filter graph
[2022-05-19 11:33:35] ffmpeg.Balcony.record          ERROR   : [mp4 @ 0x5573757dc600] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 31712 >= 752
[2022-05-19 11:33:35] ffmpeg.Balcony.record          ERROR   : av_interleaved_write_frame(): Invalid argument
[2022-05-19 11:33:35] watchdog.Balcony               INFO    : Terminating the existing ffmpeg process...
[2022-05-19 11:33:35] watchdog.Balcony               INFO    : Waiting for ffmpeg to exit gracefully...
[2022-05-19 11:33:45] ffmpeg.Balcony.record          ERROR   : [mp4 @ 0x56242df45600] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 31728 >= 768
[2022-05-19 11:33:45] ffmpeg.Balcony.record          ERROR   : av_interleaved_write_frame(): Invalid argument
[2022-05-19 11:33:45] ffmpeg.Balcony.record          ERROR   : [mp4 @ 0x56242df45600] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 31728 >= 1792
[2022-05-19 11:33:45] ffmpeg.Balcony.record          ERROR   : Error writing trailer of /tmp/cache/Balcony-%Y%m%d%H%M%S.mp4: Invalid argument
[2022-05-19 11:33:45] watchdog.Balcony               INFO    : Terminating the existing ffmpeg process...
[2022-05-19 11:33:45] watchdog.Balcony               INFO    : Waiting for ffmpeg to exit gracefully...
[2022-05-19 11:33:55] watchdog.Balcony               INFO    : No frames received from Balcony in 20 seconds. Exiting ffmpeg...
[2022-05-19 11:33:55] watchdog.Balcony               INFO    : Waiting for ffmpeg to exit gracefully...
[2022-05-19 11:33:55] frigate.video                  ERROR   : Balcony: Unable to read frames from ffmpeg process.
[2022-05-19 11:33:55] frigate.video                  ERROR   : Balcony: ffmpeg process is not running. exiting capture thread...
[2022-05-19 11:33:55] ffmpeg.Balcony.record          ERROR   : [mp4 @ 0x55a0384483c0] Application provided invalid, non monotonically increasing dts to muxer in stream 1: 31728 >= 768
[2022-05-19 11:33:55] ffmpeg.Balcony.record          ERROR   : av_interleaved_write_frame(): Invalid argument
[2022-05-19 11:33:55] watchdog.Balcony               INFO    : Terminating the existing ffmpeg process...
[2022-05-19 11:33:55] watchdog.Balcony               INFO    : Waiting for ffmpeg to exit gracefully...
[2022-05-19 11:34:05] watchdog.Balcony               ERROR   : Ffmpeg process crashed unexpectedly for Balcony.
[2022-05-19 11:34:05] watchdog.Balcony               ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.

FFprobe output from your camera

ffprobe rtsp://user:pass@192.168.1.71:554//h264Preview_01_sub
ffprobe version 4.4.1-Jellyfin Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-shared --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto --enable-gpl --enable-version3 --enable-static --enable-gmp --enable-gnutls --enable-libdrm --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libdav1d --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --arch=amd64 --enable-opencl --enable-vaapi --enable-amf --enable-libmfx --enable-vdpau --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, rtsp, from 'rtsp://-@192.168.1.71:554//h264Preview_01_sub':
  Metadata:
    title           : Session streamed by "preview"
    comment         : h264Preview_01_sub
  Duration: N/A, start: 0.000375, bitrate: N/A
  Stream #0:0: Video: h264 (High), yuv420p(progressive), 640x480, 10 tbr, 90k tbn, 180k tbc
  Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp

Frigate stats

{"Balcony":{"camera_fps":0.0,"capture_pid":242,"detection_fps":0.0,"pid":230,"process_fps":0.0,"skipped_fps":0.0},"Deck":{"camera_fps":0.0,"capture_pid":245,"detection_fps":0.0,"pid":234,"process_fps":0.0,"skipped_fps":0.0},"Driveway":{"camera_fps":0.0,"capture_pid":250,"detection_fps":0.0,"pid":235,"process_fps":0.0,"skipped_fps":0.0},"Entrance":{"camera_fps":0.0,"capture_pid":258,"detection_fps":0.0,"pid":237,"process_fps":0.0,"skipped_fps":0.0},"Laundry":{"camera_fps":0.0,"capture_pid":264,"detection_fps":0.0,"pid":238,"process_fps":0.0,"skipped_fps":0.0},"Rumpus":{"camera_fps":0.0,"capture_pid":268,"detection_fps":0.0,"pid":240,"process_fps":0.0,"skipped_fps":0.0},"detection_fps":0.0,"detectors":{"coral":{"detection_start":0.0,"inference_speed":10.0,"pid":223}},"service":{"latest_version":"0.10.1","storage":{"/dev/shm":{"free":334.6,"mount_type":"tmpfs","total":335.5,"used":0.9},"/media/frigate/clips":{"free":648808.4,"mount_type":"ext4","total":983350.1,"used":284514.7},"/media/frigate/recordings":{"free":648808.4,"mount_type":"ext4","total":983350.1,"used":284514.7},"/tmp/cache":{"free":1073.7,"mount_type":"tmpfs","total":1073.7,"used":0.0}},"temperatures":{},"uptime":1681,"version":"0.11.0-d2c3cdc"}}

Operating system

Other Linux

Install method

Docker Compose

Coral version

USB

Network connection

Wired

Camera make and model

Reolink RLC-520A

Any other information that may be helpful

docker-compose

services:
  frigate:
    container_name: frigate
    image: blakeblackshear/frigate:0.11.0-beta2
    hostname: frigate
    restart: always
    shm_size: '320m'
    devices:
      - /dev/dri/renderD128:/dev/dri/renderD128
      - /dev/bus/usb:/dev/bus/usb
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/jason/docker/frigate/config.yml:/config/config.yml:ro
      - /home/jason/docker/frigate/labelmap.txt:/labelmap.txt:ro
      - /home/jason/docker/frigate/db:/db
      - /data/frigate:/media/frigate
      - type: tmpfs
        target: /tmp/cache
        tmpfs:
          size: '1gb'
    network_mode: bridge
    ports:
      - 5000:5000
    environment:
      FRIGATE_MQTT_PASSWORD: ""
      FRIGATE_USER: ""
      FRIGATE_PASSWORD: ""

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:48 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
jasonpstokescommented, May 26, 2022

One more update for smoother clips; similar/same as they were in 0.10, vs the above configs that produced clips full of stutter.

ffmpeg:
  hwaccel_args: -hwaccel qsv -hwaccel_output_format nv12 -c:v h264_qsv
  input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000
  output_args:
    record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy

Three differences from my 0.10 config, but multiple hours of trying arguments to work that out. 🤦‍♂️

Or, as per @minglarn’s post above, use this for hardware accel using VAAPI: hwaccel_args: -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format yuv420p

2reactions
DrSpaldocommented, May 28, 2022

Yep, I have the drivers installed. Looks like I may have just had too many args in the hwaccel_args line.

Fingers crossed, this is what appears to be working for now:

  GARAGE:
    ffmpeg:
      hwaccel_args: -c:v h264_cuvid
      input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000
      output_args:
        record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy
      inputs:
        - path: rtmp://192.168.1.105/bcs/channel0_sub.bcs?channel=0&stream=1&user=USER&password=PASS
          roles:
            - rtmp
        - path: rtmp://192.168.1.105/bcs/channel0_main.bcs?channel=0&stream=1&user=USER&password=PASS
          roles:
            - detect
            - record

Originally I had quite a few things and now it is just stripped back to one for the hwaccel_args

Read more comments on GitHub >

github_iconTop Results From Across the Web

Camera Specific Configurations - Frigate Docs
In the Unifi 2.0 update Unifi Protect Cameras had a change in audio sample rate which causes issues for ffmpeg. The input rate...
Read more >
Forcing my Reolink cameras to play nice with the other kids
The problem comes when you want to integrate them with any kind of selfhosted NVR software, like Frigate, since they only support H265...
Read more >
Local realtime person detection for RTSP cameras
I have the following setup, and this is working. I only want to rotate the camera image 90 degrees, how do I do...
Read more >
Frigate - NVR With Realtime Object Detection for IP Cameras
I just cannot get the ffmpeg HW acceleration working. Tried it with the Raspi3/4 64bit version. I made frigate detection work with another ......
Read more >
Frigate - NVR With Realtime Object Detection ... - PythonRepo
I hope I'm not missing something obvious, I have been looking at this for a while before reaching out ;-). I seem unable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found