keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.59k stars 223 forks source link

Cannot use hwaccel ffmpeg arguments with frigate #293

Closed wladkolc closed 11 months ago

wladkolc commented 1 year ago

Camera

Frigate go2rtc RTSP restream

Firmware version of the camera

N/A

Description

Hi, trying to accelerate decoding stream from frigate with Intel iGPU. Anybody got this working?

Error: usage: unifi-cam-proxy frigate [-h] [--ffmpeg-args FFMPEG_ARGS]
                               [--rtsp-transport {tcp,udp,http,udp_multicast}]
                               --source SOURCE [SOURCE ...]
                               [--http-api HTTP_API]
                               [--snapshot-url SNAPSHOT_URL] --mqtt-host
                               MQTT_HOST [--mqtt-port MQTT_PORT]
                               [--mqtt-username MQTT_USERNAME]
                               [--mqtt-password MQTT_PASSWORD]
                               [--mqtt-prefix MQTT_PREFIX] --frigate-camera
                               FRIGATE_CAMERA
unifi-cam-proxy frigate: error: argument --ffmpeg-args/-f: expected one argument

My parameters:

unifi-cam-proxy -H ip -i ip --mac 'mac' -c /client.pem -t token --model "UVC G4 Pro" --fw-version "4.46.18" frigate -s 'rtsp://ip:8554/entrance' --frigate-camera entrance --mqtt-host ip --mqtt-port 1883 --mqtt-prefix frigate --ffmpeg-args '-hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p'

How to reproduce

No response

Expected behaviour

No response

Screenshots

No response

Aditional information

No response

keshavdv commented 1 year ago

Add a space before the value of the argument: --ffmpeg-args ' -hwaccel.... This is just a weird behavior of argparse (https://stackoverflow.com/questions/16174992/cant-get-argparse-to-read-quoted-string-with-dashes-in-it)

wladkolc commented 1 year ago

Hi, now i see this error in log..

ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r4) 20220924
  configuration: --prefix=/usr --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libpulse --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-lto --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-librist --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --disable-lzma --enable-libaom --enable-libopus --enable-libsoxr --enable-libwebp --enable-vaapi --enable-vdpau --enable-vulkan --enable-libdrm --enable-libzmq --optflags=-O2 --disable-debug --enable-libsvtav1
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
2023-04-26 15:34:40 5236dbe61402 FrigateCam[1] INFO Spawning ffmpeg for video1 (85Pc3Q0yEYmXkEhf): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://10.20.0.20:8554/entrance"  -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -metadata streamName=85Pc3Q0yEYmXkEhf -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 10.20.0.1 7550
2023-04-26 15:34:40 5236dbe61402 FrigateCam[1] INFO Processing [ChangeVideoSettings] message
ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.2.1 (Alpine 12.2.1_git20220924-r4) 20220924
  configuration: --prefix=/usr --enable-avfilter --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libpulse --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-lto --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-librist --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --disable-lzma --enable-libaom --enable-libopus --enable-libsoxr --enable-libwebp --enable-vaapi --enable-vdpau --enable-vulkan --enable-libdrm --enable-libzmq --optflags=-O2 --disable-debug --enable-libsvtav1
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[h264 @ 0x7f31ac225b80] reference picture missing during reorder
[h264 @ 0x7f31ac225b80] Missing reference picture, default is 2
[h264 @ 0x7f31ac225b80] reference picture missing during reorder
[h264 @ 0x7f31ac225b80] Missing reference picture, default is 34
2023-04-26 15:34:41 5236dbe61402 FrigateCam[1] INFO Spawning ffmpeg for video3 (eTJ2aDVITXC12VYi): ffmpeg -nostdin -loglevel error -y -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -timeout 15000000 -rtsp_transport tcp -i "rtsp://10.20.0.20:8554/entrance"  -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -metadata streamName=eTJ2aDVITXC12VYi -f flv - | /usr/local/bin/python -m unifi.clock_sync --write-timestamps | nc 10.20.0.1 7550
2023-04-26 15:34:41 5236dbe61402 FrigateCam[1] INFO Processing [ubnt_avclient_paramAgreement] message
Option hwaccel (use HW accelerated decoding) cannot be applied to output url - -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for output file -.
Error opening output files: Invalid argument
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

kloknibor commented 1 year ago

The reason is because the ffmpeg arguments are added at the end of line and thus the output. I created a docker container with hardcoded VAAPI support for testing and currently experimenting with that. Feel free to try it : https://hub.docker.com/r/knibor/unifi-cam-proxy no errors but I don't feel like it's helping that much so probably something is wrong

wladkolc commented 1 year ago

hi @kloknibor can you share docker files with us?

cefoster0 commented 1 year ago

same errors as above

wladkolc commented 1 year ago

my config runs without error too, but when i run intel_gpu_top i see only frigate acceleration, no ffmpeg from unifi-cam-proxy. I have tried to publish /dev/dri/renderD128 with compose file and run as privileged but without success.

kloknibor commented 1 year ago

hi @kloknibor can you share docker files with us?

See: https://github.com/kloknibor/unifi-cam-proxy

kloknibor commented 1 year ago

I am having issues with the NUC intel drivers. Can't get them to work on alpine it seems :-(

stale[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

mastercko commented 2 months ago

Commenting on this bug to reopen because it is still an issue.