AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
4.25k stars 346 forks source link

[h264_vaapi @ 0x55c0c2379240] No usable encoding profile found #366

Closed davidvf closed 10 months ago

davidvf commented 1 year ago

Hi,

Trying to switch my frigate setup to go2rtc

go2rtc:
  log:
    exec: trace
    format: text
  streams:
    voordeur:
       - "ffmpeg:http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720#video=h264#hardware"
cameras:
  voordeur:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/voordeur
          roles:
            - detect
            - record
            - rtmp
    detect:
      height: 720
      width: 1280

The above command produces the following ffmpeg exec in the logs:

exec:ffmpeg -hide_banner -hwaccel vaapi -hwaccel_output_format vaapi -fflags nobuffer -flags low_delay -i http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720 -c:v h264_vaapi -g 50 -bf 0 -profile:v high -level:v 4.1 -sei:v 0 -an -vf format=vaapi|nv12,hwupload -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp rtsp://localhost:8554/8e7e7fada0cb61f5951d7dd4b9494877"

Which is all VAAPI based... Something i never got to work in my old configuration either...

Here is a snip of the log file

2023-04-18 10:24:01.396481628  [INFO] Starting Frigate...
2023-04-18 10:24:01.398597209  [INFO] Preparing go2rtc config...
s6-rc: info: service nginx successfully started
s6-rc: info: service legacy-services: starting
2023-04-18 10:24:01.421449132  [INFO] Starting NGINX...
s6-rc: info: service legacy-services successfully started
2023-04-18 10:24:01.778898068  [INFO] Starting go2rtc...
2023-04-18 10:24:01.934756290  10:24:01.934 INF go2rtc version 1.2.0 linux/amd64
2023-04-18 10:24:01.934940303  10:24:01.934 INF [api] listen addr=:1984
2023-04-18 10:24:01.935127062  10:24:01.935 INF [rtsp] listen addr=:8554
2023-04-18 10:24:01.935287060  10:24:01.935 INF [srtp] listen addr=:8443
2023-04-18 10:24:01.935575508  10:24:01.935 INF [webrtc] listen addr=:8555
2023-04-18 10:24:02.693410631  [2023-04-18 10:24:02] frigate.app                    INFO    : Starting Frigate (0.12.0-da3e197)
2023-04-18 10:24:02.713997512  [2023-04-18 10:24:02] peewee_migrate                 INFO    : Starting migrations
2023-04-18 10:24:02.717391053  [2023-04-18 10:24:02] peewee_migrate                 INFO    : There is nothing to migrate
2023-04-18 10:24:02.740551849  [2023-04-18 10:24:02] frigate.app                    INFO    : Output process started: 293
2023-04-18 10:24:02.748903015  [2023-04-18 10:24:02] frigate.app                    INFO    : Camera processor started for voordeur: 300
2023-04-18 10:24:02.756613604  [2023-04-18 10:24:02] frigate.app                    INFO    : Capture process started for voordeur: 302
2023-04-18 10:24:02.851856033  10:24:02.851 DBG [exec] run url="exec:ffmpeg -hide_banner -hwaccel vaapi -hwaccel_output_format vaapi -fflags nobuffer -flags low_delay -i http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720 -c:v h264_vaapi -g 50 -bf 0 -profile:v high -level:v 4.1 -sei:v 0 -an -vf format=vaapi|nv12,hwupload -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp rtsp://localhost:8554/8e7e7fada0cb61f5951d7dd4b9494877"
2023-04-18 10:24:04.528320678  [mjpeg @ 0x556aea6a9940] EOI missing, emulating
2023-04-18 10:24:04.528579257  Input #0, mpjpeg, from 'http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720':
2023-04-18 10:24:04.528585783    Duration: N/A, bitrate: N/A
2023-04-18 10:24:04.528591389    Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, 25 tbr, 25 tbn
2023-04-18 10:24:04.535828682  Stream mapping:
2023-04-18 10:24:04.535835392    Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (h264_vaapi))
2023-04-18 10:24:04.535838492  Press [q] to stop, [?] for help
2023-04-18 10:24:04.594388992  [h264_vaapi @ 0x556aea6b8240] No usable encoding profile found.
2023-04-18 10:24:04.594394742  Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
2023-04-18 10:24:04.594703370  Conversion failed!
2023-04-18 10:24:04.596150012  10:24:04.596 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error="exec: exit status 1" url=ffmpeg:http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720#video=h264#hardware
2023-04-18 10:24:04.596218507  10:24:04.596 DBG [exec] run url="exec:ffmpeg -hide_banner -hwaccel vaapi -hwaccel_output_format vaapi -fflags nobuffer -flags low_delay -i http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720 -c:v h264_vaapi -g 50 -bf 0 -profile:v high -level:v 4.1 -sei:v 0 -an -vf format=vaapi|nv12,hwupload -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp rtsp://localhost:8554/8e7e7fada0cb61f5951d7dd4b9494877"
2023-04-18 10:24:05.394420784  [2023-04-18 10:24:02] detector.coral                 INFO    : Starting detection process: 292
2023-04-18 10:24:05.405733196  [2023-04-18 10:24:02] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2023-04-18 10:24:05.406440401  [2023-04-18 10:24:05] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2023-04-18 10:24:05.804668994  [mjpeg @ 0x55c0c236a940] EOI missing, emulating
2023-04-18 10:24:05.804760030  Input #0, mpjpeg, from 'http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720':
2023-04-18 10:24:05.804763602    Duration: N/A, bitrate: N/A
2023-04-18 10:24:05.804778387    Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 1280x720, 25 tbr, 25 tbn
2023-04-18 10:24:05.809068431  Stream mapping:
2023-04-18 10:24:05.809072847    Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (h264_vaapi))
2023-04-18 10:24:05.809074443  Press [q] to stop, [?] for help
2023-04-18 10:24:06.905105620  [h264_vaapi @ 0x55c0c2379240] No usable encoding profile found.
2023-04-18 10:24:06.905118958  Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
2023-04-18 10:24:06.906316283  Conversion failed!
2023-04-18 10:24:06.911262496  10:24:06.911 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error="exec: exit status 1" url=ffmpeg:http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720#video=h264#hardware
2023-04-18 10:24:06.911324129  10:24:06.911 WRN [rtsp] error="source 0 error: exec: exit status 1" stream=voordeur
2023-04-18 10:24:06.919206184  [2023-04-18 10:24:06] frigate.video                  ERROR   : voordeur: Unable to read frames from ffmpeg process.
2023-04-18 10:24:06.919820925  [2023-04-18 10:24:06] frigate.video                  ERROR   : voordeur: ffmpeg process is not running. exiting capture thread...
2023-04-18 10:24:09.111840452  192.168.0.10 - - [18/Apr/2023:10:24:09 +0200] "GET /api/stats HTTP/1.1" 200 2111 "-" "HomeAssistant/2023.4.4 aiohttp/3.8.4 Python/3.10" "-"
2023-04-18 10:24:11.413498567  [INFO] Starting go2rtc healthcheck service...
2023-04-18 10:24:18.096228059  192.168.0.10 - - [18/Apr/2023:10:24:18 +0200] "GET /api/stats HTTP/1.1" 200 2048 "-" "HomeAssistant/2023.4.4 aiohttp/3.8.4 Python/3.10" "-"
2023-04-18 10:24:22.783137216  [2023-04-18 10:24:22] watchdog.voordeur              ERROR   : Ffmpeg process crashed unexpectedly for voordeur.
2023-04-18 10:24:22.783142327  [2023-04-18 10:24:22] watchdog.voordeur              ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2023-04-18 10:24:22.783147612  [2023-04-18 10:24:22] ffmpeg.voordeur.detect         ERROR   : [rtsp @ 0x55816d0e70c0] method DESCRIBE failed: 404 Not Found
2023-04-18 10:24:22.783150544  [2023-04-18 10:24:22] ffmpeg.voordeur.detect         ERROR   : rtsp://127.0.0.1:8554/voordeur: Server returned 404 Not Found
2023-04-18 10:24:22.798987314  10:24:22.798 DBG [exec] run url="exec:ffmpeg -hide_banner -hwaccel vaapi -hwaccel_output_format vaapi -fflags nobuffer -flags low_delay -i http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720 -c:v h264_vaapi -g 50 -bf 0 -profile:v high -level:v 4.1 -sei:v 0 -an -vf format=vaapi|nv12,hwupload -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp rtsp://localhost:8554/8e7e7fada0cb61f5951d7dd4b9494877"
2023-04-18 10:24:24.430265237  [mjpeg @ 0x5617d3305940] EOI missing, emulating

This is my working config:

ffmpeg:
  global_args:
    - -hide_banner
    - -loglevel
    - warning
  hwaccel_args:
    - -hwaccel_output_format
    - qsv
    - -qsv_device
    - /dev/dri/renderD128
    - -c:v
    - h264_qsv
  input_args: -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -c:v mjpeg
  output_args:
    record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v h264_qsv -an
    rtmp: -c:v h264_qsv -an -f flv
cameras:
  voordeur:
    ffmpeg:
      inputs:
        - path: http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg?width=1280&height=720
          roles:
            - detect
            - record
            - rtmp
    detect:
      height: 720
      width: 1280
[david@owl:~ $] sudo vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.3.1 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

Any idea what i am doing wrong here?

NickM-27 commented 1 year ago

go2rtc doesn't have a quick #qsv filter, but you basically already have the command so why not use exec to run it manually?

go2rtc:
  log:
    exec: trace
    format: text
  streams:
    voordeur:
      - "exec:ffmpeg -hide_banner -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -c:v mjpeg -i http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg -c:v h264_qsv -g 50 -bf 0 -profile:v high -level:v 4.1 -user_agent -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {{output}}"
davidvf commented 1 year ago

go2rtc doesn't have a quick #qsv filter, but you basically already have the command so why not use exec to run it manually?

go2rtc:
  log:
    exec: trace
    format: text
  streams:
    voordeur:
      - "exec:ffmpeg -hide_banner -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -c:v mjpeg -i http://admin:<password>@10.69.55.228/pbhelper/stream.mjpeg -c:v h264_qsv -g 50 -bf 0 -profile:v high -level:v 4.1 -user_agent"

Oh, I was not aware I could use a syntax like that :) I'll give that a try!

NickM-27 commented 1 year ago

for some reason part of the command got clipped off so make sure to recheck what I have

AlexxIT commented 1 year ago

I think main problem with "maybe incorrect parameters such as bit_rate, rate, width or height". Does this setting work for you without hardware?

PS. You can restream your source as MJPEG. So no CPU usage at all.

AlexxIT commented 10 months ago

I think this is fixed in the latest master version

AlexxIT commented 10 months ago

https://github.com/AlexxIT/go2rtc/releases/tag/v1.8.2