我已经下载了一个软件(info-beamer),我想使用GPU加速来解码H.264视频。我知道我的平台能够使用GPU解码H.264视频。我使用以下命令使用gstreamer执行了一些测试,视频播放顺利,没有太多CPU使用:
gst-launch-1.0 filesrc location=./Sintel.mp4 ! qtdemux ! vaapidecode ! vaapisink
但是当我使用info-beamer播放相同的视频时,使用了100%的CPU。我认为如果可用的话,libavcodec会自动使用VAAPI ......我应该使用另一个库吗?我做错了什么?
我的平台正在运行带有intel HD的Atom E3826并安装了Ubuntu 14.04。
修改
我想我安装了所有必需的库:
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)
这是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
答案 0 :(得分:2)
仍然在努力,我错误地假设硬件编解码器是AVCodec =>事实并非如此。 AVHWAccel绑定到上下文它不是直接编解码器...所以avcodec_find_decoder_by_name(" h264_vaapi")不会返回任何内容。
info-beamer不支持硬件解码编解码器(h264_vaapi):
video.c代码:
video-> codec = avcodec_find_decoder(video-> codec_context-> codec_id);
我添加了
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");
显示: hw解码器 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
所以libavcodec知道这些,但是流式播放器不使用它们。
video.c中的代码声明要从avcodec_sample.0.5.0.c中分叉...所以它不是由info-beamer团队完全编写的。