How to use hardware assisted H.264 encoder(vaapih264enc) on intel CPU?

asked 2019-05-09 10:59:52 -0600

updated 2020-10-26 11:33:43 -0600

Hi All, I was able to use gstreamer x264 encoder (x264enc) to encode my video successfully. However, after a replace 'x264enc' with 'vaapi264end', the video file size is always zero. I am wondering what I have done wrong and how I can rectify it?

For diagnostic purpose, below is some information on my system: (OpenCV 4.1.0) 1. $gst-inspect-1.0 | grep vaapih264 vaapi: vaapih264enc: VA-API H.264 encoder 2. $vainfo libva info: VA-API version 0.39.4 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.3) vainfo: Driver version: Intel i965 driver for Intel(R) Kabylake - 1.7.3 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 VAProfileHEVCMain10 : VAEntrypointVLD VAProfileHEVCMain10 : VAEntrypointEncSlice VAProfileVP9Profile0 : VAEntrypointVLD VAProfileVP9Profile0 : VAEntrypointEncSlice VAProfileVP9Profile2 : VAEntrypointVLD

  1. $gst-launch-1.0 -ev videotestsrc num-buffers=60 ! timeoverlay ! vaapih264enc ! mp4mux ! filesink location=test2.mp4 => test2.mp4 created, which seems to me that vaapih264enc does work on my syste.

  2. oVideoWriter.open("appsrc ! videoconvert ! queue ! timeoverlay ! video/x-raw,width=1920,height=1080 ! vaapih264enc ! h264parse ! filesink location=test.mp4", cv::CAP_GSTREAMER,0,30,cv::Size ( 1920,1080) ) => This c statement creates a file with zero size even though a Mat image is written (oVideoWriter << image) to the file constantly.

Any thought is welcome!

Thank you for taking the time to read my post.

edit retag flag offensive close merge delete