roflcoopter / viseron

Self-hosted, local only NVR and AI Computer Vision software. With features such as object detection, motion detection, face recognition and more, it gives you the power to keep an eye on your home, office or any other place you want to monitor.
MIT License
1.66k stars 171 forks source link

Recorder component ffmpeg error on gt740/h264_nvenc in container: No capable devices found #456

Closed bsyomov closed 1 year ago

bsyomov commented 1 year ago

After some debug, error is: "lossless encoding not supported" Seems like this ffmpeg bug: https://trac.ffmpeg.org/ticket/9165 - some trouble with presets.

This command works on my host(debian 10, quite old ffmpeg), but not in container: ffmpeg -hide_banner -loglevel verbose -y -i /recordings/test.mp4 -c:v h264_nvenc -pix_fmt nv12 -movflags +faststart /recordings/test1.mp4

on host:

[h264_nvenc @ 0x559fde814240] Loaded Nvenc version 11.1
[h264_nvenc @ 0x559fde814240] Nvenc initialized successfully
[h264_nvenc @ 0x559fde814240] 1 CUDA capable devices found
[h264_nvenc @ 0x559fde814240] [ GPU #0 - < NVIDIA GeForce GT 740 > has Compute SM 3.0 ]
[h264_nvenc @ 0x559fde814240] supports NVENC

in container:

[h264_nvenc @ 0x55738218adc0] Loaded Nvenc version 11.1
[h264_nvenc @ 0x55738218adc0] Nvenc initialized successfully
[h264_nvenc @ 0x55738218adc0] 1 CUDA capable devices found
[h264_nvenc @ 0x55738218adc0] [ GPU #0 - < NVIDIA GeForce GT 740 > has Compute SM 3.0 ]
[h264_nvenc @ 0x55738218adc0] Lossless encoding not supported
[h264_nvenc @ 0x55738218adc0] No capable devices found
[h264_nvenc @ 0x55738218adc0] Nvenc unloaded

This one works in container too: ffmpeg -hide_banner -loglevel verbose -y -i /recordings/test.mp4 -c:v h264_nvenc -preset medium -pix_fmt nv12 -movflags +faststart /recordings/test1.mp4

As workaround: How i can pass "preset" or other encoder parameters to recorder output from config?

jamitupya commented 1 year ago

i think you can pass that via the ffmpeg component? maybe "input_args" or "hwaccel_args"?

also here as well.

roflcoopter commented 1 year ago

To change the codec used for the recorder you can set codec: h264_nvenc under recorder

bsyomov commented 1 year ago

i think you can pass that via the ffmpeg component?maybe "input_args" or "hwaccel_args"

I tried using "hwaccel_args", it adds ffmpeg argument before -i. Seems like I can use "input_args" for decoder, but not for encoder in "recorder" section. @roflcoopter May be we need somthing like "output_args" in "recorder" map?

To change the codec used for the recorder you can set codec: h264_nvenc under recorder

Yes, i can, but i need to change encoder settings, not encoder itself(switch "-c:v h264_nvenc" to "-c:v h264_nvenc -preset medium"). Now i am use SW h264 encoder as workaround, But h264_nvenc must work too, If I explicitly specify the "preset" parameter.

P.S. Sorry for my english, maybe my explanations are not clear?

roflcoopter commented 1 year ago

Ahh i see now what you mean. As you say a new config option is needed to support this, will get to it soon!

roflcoopter commented 1 year ago

When does this issue occur, is it when segments are concatenated? Or is it when the camera starts?

Trying to figure out the best way to solve this.

bsyomov commented 1 year ago

When segments are concatenated (and stream re-encoded in my configuration).

recorder:
        codec: h264_nvenc
        video_filters:
          - scale=1920x1080:flags=lanczos
roflcoopter commented 1 year ago

Implemented in dev tag now. You should be able to use this config now:


recorder:
  codec: h264_nvenc
  video_filters:
    - scale=1920x1080:flags=lanczos
  output_args:
    - -preset
    - medium