How to detect gpu and thus configure video toolbox params correctly via ffmpeg?

I've built an Electron application that uses ffmpeg to transcode videos. I recently incorporated use of Video ToolBox to support use of hardware acceleration for video encoding. This works nicely but fails on older machines. At runtime I need to detect whether hardware acceleration is possible and adjust or not use Video ToolBox appropriately. I've unsucessfully searched the web for information on how to do this.

Can anyone point me in the right direction on this.


Thanks and Regards

Gideon

Replies

I realise this is late, but just incase it is still relevant, I think you will find these pages helpful.


You can try and create the VT session passing this parameter : kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder () which will enable the hardware acceleration if it is available. You can then poll the session on whether it is using the hardware acceleration by querying for kVTDecompressionPropertyKey_UsingHardwareAcceleratedVideoDecode. Alternatively, request hardware acceleration by passing kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder and if it fails, revert to software decoding. Presumably similar options are available for encoding!


Good luck & all the best,

Rhys


https://developer.apple.com/documentation/************/kvtvideodecoderspecification_enablehardwareacceleratedvideodecoder?language=objc

https://developer.apple.com/documentation/************/kvtvideodecoderspecification_enablehardwareacceleratedvideodecoder?language=objc

https://developer.apple.com/documentation/************/kvtdecompressionpropertykey_usinghardwareacceleratedvideodecoder?language=objc