I would like to use hardware encoding to compress a raw video file using gstreamer and vaapi. I am getting Could not initialize supporting library
, which does not allow encoder to open. Possibly context pad peer query failed
is the root cause for this. But I am not sure. I use the following pipeline:
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
Pipeline fails with message:
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 ...
What am I doing wrong?
Using GST_DEBUG=3 gst-launch-1.0 --gst-debug-level=4
to start the pipeline gives me this:
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)
My hardware should support this and driver seems to be installed properly:
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 plugin seems to be properly installed as well:
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
...
Thank you for any suggestions.