Seems like a good idea to run the full set of capability checks only on the device that's actually about to be used. The only issue I see is that if a system has a bunch of different GPUs, of which some don't support the required capabilities, one might get unexpected results with the device indices.
Like, a system with 4 GPUs all with the required minimum nvenc version, GPU 0 and 2 support capability X. Now if you're working on GPU 0, with this patch applied, it will list all 4 GPUs as supported. So if you want to start another session, on GPU one, it will now skip that GPU, and instead end up on GPU 2. Or even worse cases might happen, the logic for this seems way overcomplicated at the moment. This is not only an issue with this patch applied. At the moment it also happens that depending on the capabilities required for an encode, the device indices might mean something else, depending on which GPUs support the required caps. That seems bad to me, having universally unique indices on the same machine no matter what settings are to be used, with some of them failing if trying to use them, would be much better. So what I propose instead of this patch: Make the device index independent of which GPUs support the required caps. Basically just means that https://github.com/FFmpeg/FFmpeg/blob/f7e9275f83ec116fc859367d61998eae8af438fc/libavcodec/nvenc.c#L365 should compare against idx instead of the nvenc_device_count. Add another check here: https://github.com/FFmpeg/FFmpeg/blob/f7e9275f83ec116fc859367d61998eae8af438fc/libavcodec/nvenc.c#L340 That aborts early if the requested ctx->device does not match idx, achieving the desired speedup. Didn't fully plan this out yet, but that plus some cosmetics, like adjusting error messages and so on, should work. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel