[Libav-user] How to favor hardware codec when decoding
Jacob Trimble
modmaker at google.com
Tue Nov 21 21:09:04 EET 2017
I am writing an application using libavcodec to decode content (which
is also using libavformat to demux). If the platform supports it, I
want to use a hardware decoder if possible, but avcodec_find_decoder
always returns the software decoder.
For example, when decoding h264, on Linux I want to use the
"h264_cuvid" decoder, on Mac/iOS I want to use the "h264" decoder with
the AV_HWDEVICE_TYPE_VIDEOTOOLBOX hwaccel, on others I want to use the
normal "h264" software decoder.
I can use av_hwdevice_iterate_types to find the first hwaccel for the
system; but that may not support the current codec, while another
might (if there are multiple). Also, it doesn't allow me to get
"h264_cuvid" on Linux.
I also tried using the codec name as a prefix (i.e. looking for any
supported codec that starts with "h264_"). But this doesn't work with
"aac" since there is "aac_latm". I also can't use the hwdevice name
since that would be "cuda" on Linux, not "cuvid".
I want to avoid hard-coding any of these mappings or using hacky
string manipulation that depends on the name of the codec. Is there a
way to get a hardware codec for some codec ID/name? Is there a way to
detect if a given hwdevice supports some codec (e.g. does videotoolbox
support "vp9")?
More information about the Libav-user
mailing list