[Libav-user] av_hwdevice_ctx_create fails when using AV_HWDEVICE_TYPE_CUDA

Santosh Kamble skamble at cemtrexlabs.com
Tue Jul 5 15:31:12 EEST 2022


Helo dr.strashni,
I tried this, though LOG(LOG_LEVEL_ERROR) was not compiling.
the output is:
Available device types:
dxva2
d3d11va

output does not contain cuda.
but as I mentioned in my issue post, ffmpeg outputs it in hardware
accelerators list.

On Tue, Jul 5, 2022 at 4:59 PM Strahinja Radman <dr.strashni at gmail.com>
wrote:

>
>
> > On 5. 7. 2022., at 11:10, Santosh Kamble <skamble at cemtrexlabs.com>
> wrote:
> >
> > Helo,
> > I am trying to decode a video stream in C++ application using ffmpeg
> cuda hardware acceleration.
> > My windows machine has GPU is GTX1060  Update driver version 512.59
> >
> >
> > err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_CUDA,
> > NULL, NULL, 0)
> >
> > Function fails with errorcode -12
> > but when I pass AV_HWDEVICE_TYPE_DXVA2, it succeeds.
> >
> > ----------------------------
> > My observations about ffmpeg cuda compiled tool :
> >   I observed that cuda based image decoding and video decoding is
> working fine using ffmpeg tool as below example works and use GPU for
> decoding purpose.
> > ex1. ffmpeg -hwaccel cuda -i "D:\myvideo.avi"  output.mp4
> > ex2. ffmpeg -hwaccel cuda -i D:\myvideo.mp4 -y ./tests/%04d.jpg
> >
> > also the tool shows it supports cuda hardware acceleration.
> > command:  ffmpeg.exe -hwaccels
> > output: ffmpeg version 4.4.git Copyright (c) 2000-2022 the FFmpeg
> developers
> >   built with Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30140
> for x64
> >   configuration: --enable-nonfree --enable-shared --enable-ffnvcodec
> --enable-cuda-llvm --enable-gpl --disable-debug --enable-cuda-nvcc
> --enable-libnpp --toolchain=msvc --extra-cflags=-I../nv_sdk
> --extra-ldflags='-libpath:../nv_sdk' --nvccflags='-gencode
> arch=compute_60,code=sm_60 -O2'
> >   libavutil      57. 24.101 / 57. 24.101
> >   libavcodec     59. 28.100 / 59. 28.100
> >   libavformat    59. 23.100 / 59. 23.100
> >   libavdevice    59.  6.100 / 59.  6.100
> >   libavfilter     8. 38.100 /  8. 38.100
> >   libswscale      6.  6.100 /  6.  6.100
> >   libswresample   4.  6.100 /  4.  6.100
> >   libpostproc    56.  5.100 / 56.  5.100
> > Hardware acceleration methods:
> > cuda
> > dxva2
> > d3d11va
> >
> >
> > -----------------------------------------
> >
> >
> > So it looks like the compiled libraries are fine. I am missing some
> other thing.
> > Can someone help on this cuda based decoding using ffmpeg.
> >
> >
> > Thanks
> > Santosh
> > _______________________________________________
> > Libav-user mailing list
> > Libav-user at ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/libav-user
> >
> > To unsubscribe, visit link above, or email
> > libav-user-request at ffmpeg.org with subject "unsubscribe”.
>
>
> Hello Santosh,
>
> You can try this piece of code in order to get the type by name or search
> for available types for your GPU.
>
>     type = av_hwdevice_find_type_by_name("cuda");
>     if (type == AV_HWDEVICE_TYPE_NONE)
>     {
>         LOG(LOG_LEVEL_ERROR) << "Device type " << "cuda" << " is not
> supported.";
>         LOG(LOG_LEVEL_ERROR) << "Available device types:";
>         while ((type = av_hwdevice_iterate_types(type)) !=
> AV_HWDEVICE_TYPE_NONE)
>             LOG(LOG_LEVEL_INFO) << av_hwdevice_get_type_name(type);
>     }
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20220705/cc1e4d2f/attachment.htm>


More information about the Libav-user mailing list