Search code examples
ffmpeghardware-acceleration

can we set FFMPEG hardware acceleration if driver available otherwise use default?


I need to set ffmpeg code in such a way that if hardware acceleration is available it should be use it otherwise go with the available default driver. I am working with a screen recording software which is programmed in visual c++. So I need to implement hardware acceleration if it installed computer have GPU, otherwise go with the CPU.

ffmpeg -hwaccel cuda -f gdigrab -framerate 24 -probesize 42M -i desktop  -preset ultrafast -pix_fmt yuv420p camera1.mp4

I tried the above code but it is not working because my computer doesn't have CUDA or GPU support


Solution

  • List available hardware acceleration methods

    See the -hwaccels option:

    -hwaccels
    List all hardware acceleration methods supported in this build of ffmpeg.

    Example:

    $ ffmpeg -v error -hwaccels
      Hardware acceleration methods:
      vdpau
      cuda
      vaapi
      qsv
      drm
    

    Or use auto

    To automatically select the hardware acceleration method:

    ffmpeg -hwaccel auto -i input ... output