[FFmpeg-devel] [PATCH] (for discussion): ffmpeg: prefer cuvid decoders when use option -cuvid

wm4 nfxjfg at googlemail.com
Mon Feb 13 06:08:53 EET 2017


On Sun, 12 Feb 2017 21:20:12 +0000
Mark Thompson <sw at jkqxz.net> wrote:

> On 12/02/17 20:37, Miroslav Slugeň wrote:
> > This patch is for discussion only, not ready to commit yet and maybe newer will be.
> > 
> > We were facing issue when using -hwaccel cuvid we have to also specify input decoder like -c:v XXXX_cuvid for every input and input video format was sometimes mpeg2/h264/hevc. So this is my FIX/HACK to only specify -cuvid and ffmpeg will pick cuvid decoder for any supported input.
> > 
> > I don't know correct solution for this yet.  
> 
> Adding global variables to libraries to mess with their internals is not an acceptable solution to anything.
> 
> The correct solution to this problem is to write a real cuvid hwaccel, which works within the existing decoder to offer decoding of streams which it supports without changing the behaviour at all in normal software cases (compare the behaviour of cuvid (standalone decoder) with dxva2, vaapi or vdpau (full hwaccels inside the normal decoder)).
> 
> An alternative solution for your specific case would be to disable the normal H.264, MPEG-2, etc. decoders in your build, such that the cuvid decoder appears first in the list and would always be picked for any given stream.  (This of course would also remove support for the wider set of streams which the libavcodec decoders support, such as H.264 at higher big depths, though given that your patch here also has that effect I assume you aren't particularly concerned about that case.)

What's the problem with just specifying the correct decoder? Both API
and ffmpeg.c allow doing this.

Although what I don't like is that API users need to do not-so-clean
things to find the right decoder, e.g. relying on the naming
conventions, and assuming you can get the the cuda wrapper by
concatenating the codec and API names e.g. h264 -> "h264_cuda".
Maybe adding decoder and API fields to AVHWAccel would be nice.
Then ffmpeg.c could get an option to select codecs by API too.


More information about the ffmpeg-devel mailing list