I have downloaded a software (info-beamer) and I would like to use the GPU acceleration to decode H.264 videos. I know my platform is able to decode H.264 videos by using the GPU. I performed some tests with gstreamer using the following command and the video plays smoothly without too much CPU usage:
gst-launch-1.0 filesrc location=./Sintel.mp4 ! qtdemux ! vaapidecode ! vaapisink
But when I play the same video with info-beamer 100% of the CPU is used. I thought libavcodec would automatically use VAAPI if available ... Should I use another library? What am I doing wrong?
My platform is running an Atom E3826 with intel HD and has Ubuntu 14.04 installed.
EDIT:
I think I installed all the required libraries:
nap@nap:~$ dpkg -l | grep libva
ii libva-dev:amd64 1.3.0-2 amd64 Video Acceleration (VA) API for Linux -- development files
ii libva-drm1:amd64 1.3.0-2 amd64 Video Acceleration (VA) API for Linux -- DRM runtime
ii libva-egl1:amd64 1.3.0-2 amd64 Video Acceleration (VA) API for Linux -- EGL runtime
ii libva-glx1:amd64 1.3.0-2 amd64 Video Acceleration (VA) API for Linux -- GLX runtime
ii libva-intel-vaapi-driver 1.3.0-1ubuntu1 all VAAPI driver for Intel G45 & HD Graphics family (transitional package)
ii libva-tpi1:amd64 1.3.0-2 amd64 Video Acceleration (VA) API for Linux -- TPI runtime
ii libva-wayland1:amd64 1.3.0-2 amd64 Video Acceleration (VA) API for Linux -- Wayland runtime
ii libva-x11-1:amd64 1.3.0-2 amd64 Video Acceleration (VA) API for Linux -- X11 runtime
ii libva1:amd64 1.3.0-2 amd64 Video Acceleration (VA) API for Linux -- runtime
nap@nap:~$ dpkg -l | grep vaapi
ii gstreamer1.0-vaapi:amd64 0.5.7-0ubuntu4 amd64 VA-API plugins for GStreamer
ii libgstreamer-vaapi1.0-0:amd64 0.5.7-0ubuntu4 amd64 GStreamer libraries from the "vaapi" set
ii libva-intel-vaapi-driver 1.3.0-1ubuntu1 all VAAPI driver for Intel G45 & HD Graphics family (transitional package)
Here is the output of vainfo:
nap@nap:~$ sudo vainfo
error: XDG_RUNTIME_DIR not set in the environment.
libva info: VA-API version 0.35.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_35
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.35 (libva 1.3.0)
vainfo: Driver version: Intel i965 driver - 1.3.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
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileNone : VAEntrypointVideoProc
VAProfileJPEGBaseline : VAEntrypointVLD
Still working on , i wrongly assumed hardware codec was a AVCodec => it is not the case. AVHWAccel is bound to context it is not the direct codec... so avcodec_find_decoder_by_name("h264_vaapi") won't return anything.
info-beamer does not support hardware decoding codec ( which is h264_vaapi ) :
video.c code :
video->codec = avcodec_find_decoder(video->codec_context->codec_id);
i added
if (video->codec_context->hwaccel != NULL)
{
fprintf(stderr, "HW accel IN USE : %s\n", video->codec_context->hwaccel->name);
}
else
{
fprintf(stderr, "NO HW accel IN USE\n");
}
and "NO HW accel IN USE\n" is displayed, while i checked previously that it is registered :
fprintf(stderr,"\n hw Decoders\n");
AVHWAccel *first_hwaccel = av_hwaccel_next(NULL);
fprintf(stderr,"%p", first_hwaccel);
AVHWAccel *hwaccel = first_hwaccel;
AVHWAccel *h264 = NULL;
const char * h264_name = "h264_vaapi";
while (hwaccel != NULL)
{
if ( hwaccel != NULL)
{
fprintf(stderr,"%s ", hwaccel->name);
if (strcmp(hwaccel->name, h264_name)== 0)
{
h264=hwaccel;
}
}
hwaccel=av_hwaccel_next(hwaccel);
if (hwaccel == first_hwaccel)
{
break;
}
}
fprintf(stderr,"\n");
It displays : hw Decoders 0x7f19af53fa80h263_vaapi h263_vdpau h264_vaapi h264_vdpau mpeg1_vdpau mpeg2_vaapi mpeg2_vdpau mpeg4_vaapi mpeg4_vdpau vc1_vaapi vc1_vdpau wmv3_vaapi wm3 _vdpau
so libavcodec knows about those but stream-beamer does not use them.
video.c code claims in header to be forked from avcodec_sample.0.5.0.c ... so it was not fully written by info-beamer team.