title: Enable hardware (GPU) video decode acceleration with ffmpeg C API?
body: <p>I am using <code>avcodec_decode_video2()</code> to decode a particular video without enabling any GPU hardware support.</p>
  
  <p>While I tried to get the hardware decoder by name:</p>
  
  <pre><code>mVideoCodec = avcodec_find_decoder_by_name("h264_dxva2");
  </code></pre>
  
  <p>But its results <code>mVideoCodec = NULL</code> although while running ffmpeg from command prompt using dxva2 hwaccel, no error is being shown. Here I am giving the configuration output what I got from the command prompt. can anyone please tell me how can I enable hardware acceleration properly while using <code>avcodec_decode_video2()</code> API to decode the video in C.</p>
  
  <p>I am using a laptop with an NVIDIA GPU.</p>
  
  <p>Log from command prompt:</p>
  
  <blockquote>
    <p>C:\ffmpeg\bin>ffmpeg -hwaccel dxva2 -i 9.mp4 -r 60 -vsync 0 -f image2 image-%2d.png**
    configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx</p>
  </blockquote>