<div dir="ltr">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).</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 21, 2017 at 5:16 PM Jacob Trimble <<a href="mailto:modmaker-at-google.com@ffmpeg.org">modmaker-at-google.com@ffmpeg.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am writing an application using libavcodec to decode content (which<br>
is also using libavformat to demux).  If the platform supports it, I<br>
want to use a hardware decoder if possible, but avcodec_find_decoder<br>
always returns the software decoder.<br>
<br>
For example, when decoding h264, on Linux I want to use the<br>
"h264_cuvid" decoder, on Mac/iOS I want to use the "h264" decoder with<br>
the AV_HWDEVICE_TYPE_VIDEOTOOLBOX hwaccel, on others I want to use the<br>
normal "h264" software decoder.<br>
<br>
I can use av_hwdevice_iterate_types to find the first hwaccel for the<br>
system; but that may not support the current codec, while another<br>
might (if there are multiple).  Also, it doesn't allow me to get<br>
"h264_cuvid" on Linux.<br>
<br>
I also tried using the codec name as a prefix (i.e. looking for any<br>
supported codec that starts with "h264_").  But this doesn't work with<br>
"aac" since there is "aac_latm".  I also can't use the hwdevice name<br>
since that would be "cuda" on Linux, not "cuvid".<br>
<br>
I want to avoid hard-coding any of these mappings or using hacky<br>
string manipulation that depends on the name of the codec.  Is there a<br>
way to get a hardware codec for some codec ID/name?  Is there a way to<br>
detect if a given hwdevice supports some codec (e.g. does videotoolbox<br>
support "vp9")?<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</blockquote></div>