I have a project that uses FFmpeg to decode video streams and I want to make use of hardware decoding where available. According to this answer, the use of ff_find_hwaccel
and friends is deprecated in newer FFmpeg builds.
The answer states that ff_find_hwaccel
is deprecated. I want to know how the new method for allocating a hardware accelerated decoder works. Is it done automatically? Can I just pass hwaccel
in an AvDictionary as the third option to avcodec_open2
, or do I have to do something more involved?
Currently the code for allocating an AVCodecContext
looks like this:
auto video_codec = avcodec_find_decoder(codec_id);
auto context = avcodec_alloc_context3(video_codec);
auto retcode = avcodec_open2(context, video_codec, nullptr);
with error checking, of course.
I then push AVPackets into the decoder using avcodec_decode_video2
.