[Libav-user] How to use hardware acceleration?

Philippe Gorley philippe.gorley at savoirfairelinux.com
Tue Aug 15 22:03:56 EEST 2017


On 2017-08-07 07:16 PM, Wagner Patriota wrote:
> 1. Is there a generic/multi-platform logic/flow for enabling the 
> hardware acceleration for encoders/decoders using only FFmpeg API?

Nothing like a on/off switch. There's a bit of work to do to benefit 
from hardware acceleration.

> 
> 2. I noticed that FFmpeg source code has separated files like 
> ffmpeg_dxva2.c, ffmpeg_videotoolbox.c, etc and uses them to prepare some 
> stuff before using the hardware acceleration.
> Supposing I don't know anything about the underlying of the hardware 
> acceleration and just want to use it without having to deal with 
> platform specific code... is it possible? is there a good example for this?

Unfortunately, since every API is developed by different entities, it is 
near impossible to make them all follow the same workflow. A lot of work 
is being done here to make it as painless as possible.

As for an example, I've managed to implement vaapi, vdpau, videotoolbox 
and vda in GNU Ring (mirror here: 
https://github.com/savoirfairelinux/ring-daemon). Files of interest are 
src/media/media_decoder.cpp, src/media/video/accel.h, 
src/media/video/accel.cpp, src/media/video/v4l2/vaapi.cpp, 
src/media/video/v4l2/vdpau.cpp, and 
src/media/video/osxvideo/videotoolbox.cpp

VLC, mpv and the ffmpeg command-line tool use the hwaccel API.

> 
> 3. I noticed that the special case of the VDA exposes the decoder 
> "h264_vda" as an AVCodec just like any other codecs... why not do this 
> for all the other hardware acceleration? like DXVA2, QuickSync, NVENC, 
> etc...

Those are standalone accelerated codecs. I'm not sure why exactly this 
was replaced by the hwaccel API.

I don't think hardware encoding follows a similar API within FFmpeg. 
Most of them are standalone codecs from what I've seen.

> 
> 
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
> 

Cheers,

-- 
Philippe Gorley
Free Software Consultant | Montréal, Qc
Savoir-faire Linux

Confidentiality Message: This communication (including any files
transmitted with it) is intended solely for the person or entity to
whom it is addressed, and may contain confidential or privileged
information.
The disclosure, distribution or copying of this message is strictly
forbidden. Should you have received this communication in error,
kindly contact the sender promptly, destroy any copies and delete
this message from your computer system.


More information about the Libav-user mailing list