[FFmpeg-devel] Howto utilize GPU acceleration outside expected places?

Lynne dev at lynne.ee
Thu Oct 10 09:06:28 EEST 2024


On 10/10/2024 06:05, martin schitter wrote:
> 
> Can someone here point me to an example, how to use GPU acceleration 
> outside of external hw_decode/encode facilities or vulkan_filters, just 
> as more suitable compute mechanism and for better float image data 
> support in ordinary ffmpeg code modules?
> 
> Most examples and documentation are only focused on external hardware 
> accelerated en-/decoding or isolated vulkan/placebo filters, but I'm 
> more interested in using compute shaders just as alternative execution 
> path in common ffmpeg code whenever the required hardware is accessible. 
> It would be very helpful to have an instructive working example for 
> efficient use of this kind of more silent GPGPU inclusion.

You can copy libavutil/vulkan* into whatever project you want, and 
change 4 #include lines to make it compile.
This lets you use the same API to construct and execute shaders as you 
would within lavc/lavfi/lavu into your own project. You will need to 
make libavutil a dependency as hwcontext_vulkan.c cannot be exported and 
must remain within libavutil.

That's what I did for https://github.com/cyanreg/ldpc_matrix_opt/
Works great thanks to all the work I put in.

Otherwise, of course you can do it the long way by either writing your 
own or using another framework.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0xA2FEA5F03F034464.asc
Type: application/pgp-keys
Size: 624 bytes
Desc: OpenPGP public key
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241010/afa56925/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241010/afa56925/attachment.sig>


More information about the ffmpeg-devel mailing list