[Libav-user] How to favor hardware codec when decoding
Jacob Trimble
modmaker at google.com
Wed Nov 22 01:09:13 EET 2017
On Tue, Nov 21, 2017 at 1:03 PM, Leandro Moreira
<leandro.ribeiro.moreira at gmail.com> wrote:
> I think you can use these two functions: avcodec_find_encoder_by_name(name)
> and avcodec_find_decoder_by_name(name) but they require you to know your
> decoder name before (ffmpeg -decoders).
I don't know the decoder name ahead of time and I don't want to
hardcode the mappings. All I know is I need an h264 decoder, I don't
want to hardcode "h264_cuvid". (I am also using h264 only as an
example, I want a general solution)
I was able to get a working solution using av_codec_next to traverse
all supported codecs looking for one that matches the codec ID but
doesn't match the "plain" codec name. Seems like a hack, but it
should work.
Is there any way to detect what hwaccels are available? Specifically
whether a hwdevice supports a given codec? I can just always
initialize the one returned from
av_hwdevice_iterate_types(AV_HWDEVICE_TYPE_NONE), which will do
nothing if the hwdevice doesn't support the codec. But if the
platform supports multiple hwdevice types, this is not optimal since I
can't detect whether the hwdevice supports the current codec. Again,
I don't want to hardcode that "if this is h264, on iOS, and we are
configured to include VIDEOTOOLBOX, then use VIDEOTOOLBOX".
More information about the Libav-user
mailing list