1

我想使用硬件编码使用 gstreamer 和 vaapi 压缩原始视频文件。我得到了Could not initialize supporting library,它不允许打开编码器。可能context pad peer query failed是造成这种情况的根本原因。但我不确定。我使用以下管道:

gst-launch-1.0 -v filesrc location=input.raw ! videoparse width=1280 height=1024 format=yuy2 framerate=20/1 ! vaapih264enc ! h264parse ! qtmux ! filesink location=compressed.mov

管道失败并显示消息:

Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstVaapiEncodeH264:vaapiencodeh264-0: Could not initialize supporting library.
Additional debug info:
gstvideoencoder.c(1534): gst_video_encoder_change_state (): /GstPipeline:pipeline0/GstVaapiEncodeH264:vaapiencodeh264-0:
Failed to open encoder
Setting pipeline to NULL ...
Freeing pipeline ...

我究竟做错了什么?

使用GST_DEBUG=3 gst-launch-1.0 --gst-debug-level=4启动管道给了我这个:

INFO       GST_STATES gstbin.c:2316:gst_bin_element_set_state:<vaapiencodeh264-0> current NULL pending VOID_PENDING, desired next READY
INFO      GST_CONTEXT gstvaapivideocontext.c:106:context_pad_query:<vaapiencodeh264-0:src> context pad peer query failed
INFO      GST_CONTEXT gstvaapivideocontext.c:106:context_pad_query:<vaapiencodeh264-0:sink> context pad peer query failed
INFO      GST_CONTEXT gstvaapivideocontext.c:180:_gst_context_query:<vaapiencodeh264-0> posting `need-context' message
INFO            vaapi gstvaapidisplay.c:119:libgstvaapi_init_once: gstreamer-vaapi version
WARN     videoencoder gstvideoencoder.c:1534:gst_video_encoder_change_state:<vaapiencodeh264-0> error: Failed to open encoder
INFO GST_ERROR_SYSTEM gstelement.c:1879:gst_element_message_full:<vaapiencodeh264-0> posting message: Could not initialize supporting library.
INFO GST_ERROR_SYSTEM gstelement.c:1902:gst_element_message_full:<vaapiencodeh264-0> posted error message: Could not initialize supporting library.
INFO       GST_STATES gstelement.c:2657:gst_element_change_state:<vaapiencodeh264-0> have FAILURE change_state return
INFO       GST_STATES gstelement.c:2247:gst_element_abort_state:<vaapiencodeh264-0> aborting state from NULL to READY
INFO       GST_STATES gstbin.c:2780:gst_bin_change_state_func:<pipeline0> child 'vaapiencodeh264-0' failed to go to state 2(READY)

我的硬件应该支持这一点,并且驱动程序似乎安装正确:

shell:~$ vainfo
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 1.7.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :    VAEntrypointVLD
      VAProfileMPEG2Simple            :    VAEntrypointEncSlice
      VAProfileMPEG2Main              :    VAEntrypointVLD
      VAProfileMPEG2Main              :    VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:    VAEntrypointEncSlice
      VAProfileH264Main               :    VAEntrypointVLD
      VAProfileH264Main               :    VAEntrypointEncSlice
      VAProfileH264High               :    VAEntrypointVLD
      VAProfileH264High               :    VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      :    VAEntrypointVLD
      VAProfileH264MultiviewHigh      :    VAEntrypointEncSlice
      VAProfileH264StereoHigh         :    VAEntrypointVLD
      VAProfileH264StereoHigh         :    VAEntrypointEncSlice
      VAProfileVC1Simple              :    VAEntrypointVLD
      VAProfileVC1Main                :    VAEntrypointVLD
      VAProfileVC1Advanced            :    VAEntrypointVLD
      VAProfileNone                   :    VAEntrypointVideoProc
      VAProfileJPEGBaseline           :    VAEntrypointVLD
      VAProfileJPEGBaseline           :    VAEntrypointEncPicture
      VAProfileVP8Version0_3          :    VAEntrypointVLD
      VAProfileVP8Version0_3          :    VAEntrypointEncSlice
      VAProfileHEVCMain               :    VAEntrypointVLD
      VAProfileHEVCMain               :    VAEntrypointEncSlice

vaapi 插件似乎也已正确安装:

gst-inspect-1.0 vaapih264enc
Factory Details:
  Rank                     primary (256)
  Long-name                VA-API H.264 encoder
  Klass                    Codec/Encoder/Video
  Description              A VA-API based H.264 video encoder
  Author                   Wind Yuan <feng.yuan@intel.com>

Plugin Details:
  Name                     vaapi
  Description              VA-API based elements
  Filename                 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so
  Version                  1.8.3
  License                  LGPL
  Source module            gstreamer-vaapi
  Source release date      2016-06-09
  Binary package           gstreamer-vaapi
  Origin URL               http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer
...

感谢您的任何建议。

4

1 回答 1

0

我相信不正确的用户配置/权限是无法初始化编码器库的原因。如果知道如何在我的系统上的某个地方找到一些日志消息以将我指向那个方向,那就太好了(这对我来说是一个幸运的绊脚石)。

在更改了两件事后,我得到了硬件编码:1)我运行这些命令的用户没有正确的权限或配置。我还没有调查到底是什么。2)一旦我使用了正确的用户帐户,我就会收到一条错误消息,建议我vaapipostproc以前使用vaapih264enc它来解决 en 无法理解的色度类型。

我使用的最后一个管道命令是:sudo -u proper_user gst-launch-1.0 filesrc location=input.raw ! videoparse width=1280 height=1024 format=yuy2 framerate=20/1 ! videoconvert ! vaapipostproc ! vaapih264enc ! qtmux ! filesink location=hardware.compressed.mov

于 2019-09-06T19:46:56.513 回答