implement the necessary HW accelerated decoding on OS X (VDA) and Linux (VDPAU). I will update the answer when I get my hands on Windows implementation as well. So let’s start with the easiest:
Mac OS X
To get HW acceleration working on Mac OS you should just use the following: avcodec_find_decoder_by_name("h264_vda"); Note, however that you can accelerate h264 videos only on Mac OS with FFmpeg.
On Linux things are much more complicated(who is surprised?). FFmpeg has 2 HW accelerators on Linux: VDPAU(Nvidia) and VAAPI(Intel) and only one HW decoder: for VDPAU. And it may seems perfectly reasonable to use vdpau decoder like in the Mac OS example above: avcodec_find_decoder_by_name("h264_vdpau");
You might be surprised to find out that it doesn’t change anything and you have no acceleration at all. That’s because it is only the beginning, you have to write much more code to get the acceleration working. Happily, you don’t have to come up with a solution on your own: there are at least 2 good examples of how to achieve that: libavg and FFmpeg itself. libavg has VDPAUDecoder class which is perfectly clear and which I’ve based my implementation on. You can also consult ffmpeg_vdpau.c to get another implementation to compare. In my opinion the libavg implementation is easier to grasp, though.
The only things both aforementioned examples lack is proper copying of the decoded frame to the main memory. Both examples uses VdpVideoSurfaceGetBitsYCbCr which killed all the performance I gained on my machine. That’s why you might want to use the following procedure to extract the data from a GPU:
bool VdpauDecoder::fillFrameWithData(AVCodecContext* context,
VdpauDecoder* vdpauDecoder = static_cast<VdpauDecoder*>(context->opaque);
vdp_output_surface_create(m_VdpDevice, VDP_RGBA_FORMAT_B8G8R8A8, frame->width, frame->height, &;surface);
auto renderState = reinterpret_cast<vdpau_render_state*>(frame->data);
VdpVideoSurface videoSurface = renderState->surface;
auto status = vdp_video_mixer_render(vdpauDecoder->m_VdpMixer,
nullptr, nullptr, 0, nullptr);
if(status == VDP_STATUS_OK)
auto tmframe = av_frame_alloc();
tmframe->format = AV_PIX_FMT_BGRA;
tmframe->width = frame->width;
tmframe->height = frame->height;
if(av_frame_get_buffer(tmframe, 32) >= 0)
VdpStatus status = vdp_output_surface_get_bits_native(surface, nullptr,
reinterpret_cast<void * const *>(tmframe->data),
reinterpret_cast<const uint32_t *>(tmframe->linesize));
if(status == VDP_STATUS_OK &;&; av_frame_copy_props(tmframe, frame) == 0)
While it has some "external" objects used inside you should be able to understand it once you have implemented the "get buffer" part(to which the aforementioned examples are of great help). Also I’ve used BGRA format which was more suitable for my needs maybe you will choose another.
The problem with all of it is that you can’t just get it working from FFmpeg you need to understand at least basics of the VDPAU API. And I hope that my answer will aid someone in implementing the HW acceleration on Linux. I’ve spent much time on it myself before I realized that there is no simple, one-line way of implementing HW accelerated decoding on Linux.
Since my original question was regarding VA-API I can’t not leave it unanswered. First of all there is no decoder for VA-API in FFmpeg so avcodec_find_decoder_by_name("h264_vaapi") doesn’t make any sense: it is nullptr. I don’t know how much harder(or maybe simpler?) is to implement decoding via VA-API since all the examples I’ve seen were quite intimidating. So I choose not to use VA-API at all and I had to implement the acceleration for an Intel card. Fortunately enough for me, there is a VDPAU library(driver?) which works over VA-API. So you can use VDPAU on Intel cards!
I’ve used the following link to setup it on my Ubuntu.
Also, you might want to check the comments to the original question where @Timothy_G also mentioned some links regarding VA-API.
Axure汉化版已经发布，版本号Axure 22.214.171.1249，下面是截图效果 Axure汉化版文件下载地址：Axure汉化补丁 Axure RP pro 126.96.36.1999 下载地址注册用户名：Axure 序列...
BI中文站 6月7日报道 艾默生·斯帕茨(Emerson Spartz)今年28岁，已婚，是Spartz Inc公司的首席执行官。Spartz Inc是一个网站媒体帝国，旗下的30多家网站专门发布有趣、励志和让人感到不可思议的文章和帖子，其分享量非常...
- 【每日一博】Mysql Fabric 实现学习笔记
- 配置Spring JDBC的事务回滚失效
- mysql command line client 使用命令
- mysql 触发器
- Location of MySQL&amp;#x27;s my.cnf file
- MySQL Date Gotchas
- mysql 创建定时器
- Speaking at Oracle OpenWorld 2014