无法使用 nvh265enc gstreamer 插件的无损预设

Unable to use the lossless preset of the nvh265enc gstreamer plugin

我正在使用 gstreamer 1.18(使用 gst-build 构建)。我正在尝试使用 nvh265enc 插件的无损预设。通过以下管道,我可以成功使用除无损预设(lossless (6) 和 lossless-hp (7))之外的所有预设:

gst-launch-1.0 videotestsrc ! nvh265enc preset=6 ! h265parse ! nvh265dec ! glimagesink

每当我将 preset 设置为 6 或 7 时,我都会收到以下错误。

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Got context from element 'sink': gst.gl.GLDisplay=context, gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayX11\)\ gldisplayx11-0";
Got context from element 'nvh265dec0': gst.cuda.context=context, gst.cuda.context=(GstCudaContext)"\(GstCudaContext\)\ cudacontext0", cuda-device-id=(int)0;
ERROR: from element /GstPipeline:pipeline0/GstNvH265Enc:nvh265enc0: Could not configure supporting library.
Additional debug info:
../subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.c(1712): gst_nv_base_enc_set_format (): /GstPipeline:pipeline0/GstNvH265Enc:nvh265enc0:
Failed to init encoder: 8
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
ERROR: from element /GstPipeline:pipeline0/GstNvH265Enc:nvh265enc0: Could not configure supporting library.
Additional debug info:
../subprojects/gst-plugins-bad/sys/nvcodec/gstnvbaseenc.c(1712): gst_nv_base_enc_set_format (): /GstPipeline:pipeline0/GstNvH265Enc:nvh265enc0:
Failed to init encoder: 8
ERROR: pipeline doesn't want to preroll.
Freeing pipeline ...

更令人费解的是,无损预设适用于 Nvidia Video Codec SDK 9 中的样本。

我是否遗漏了任何其他配置?

编辑:最后我发现将 qp-const=0rc-mode=1 添加到 nvh265enc 有效。

嗯,首先,无损和无损-hp没有区别。

https://superuser.com/questions/1528215/what-is-the-difference-between-nvenc-hevc-lossless-and-losslesshp-presets

其次,Gstreamer不是Nvidia原生支持的应用程序。另一方面,FFmpeg 是。例如,GS 也不支持 B 帧作为参考模式及其两个子模式(中间和每个)。参见:https://forum.videohelp.com/threads/387613-Nvidia-h-265-hevc-lossless#post2509093

ffmpeg -vsync 0 -r 60 -hwaccel cuda  -hwaccel_output_format cuda -i "in.mp4" -c:v hevc_nvenc -preset lossless "out.mp4"

P.S。 Gstreamer 支持 rc-mode=1 或 qp-const=0 的无损。