<div dir="ltr">I got the latest version binaries of ffmpeg from <a href="https://ffmpeg.zeranoe.com/builds/" target="_blank">here</a>.
 When I examine CPU and GPU usages when I play a video by its ffplay, I 
see that GPU is used during play. Not much using of CPU also indicates 
it. But when I get the latest version sources from the original site, I 
can't use GPU. To clarify, I include a player test program I wrote until
 now. When I uncomment the line which includes 
avcodec_find_decoder_by_name("h264_cuvid"), I get error -1. The error 
happens in avcodec_open2 with the description of Operation not 
permitted.<div class="gmail_quote"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div dir="ltr"><div style="font-family:tahoma,sans-serif;font-size:small"><br></div><div style="font-family:tahoma,sans-serif;font-size:small">CString format(const char *fmt, ...) <br>{ <br>    va_list ap;<br>    va_start(ap, fmt);<br>    char buf[512];<br>    vsnprintf(buf, sizeof(buf), fmt, ap);<br>    va_end(ap);<br>    return buf;<br>}<br><br>int CplayerDlg::play()<br>{<br>    FILE *fp = fopen("video_files/1010.brf", "rb");<br>    if (!fp)<br>    {<br>        AfxMessageBox("can't open video file");<br>        return -1;<br>    }<br>    RecordFrame frame;<br>    RecordHeader hdr;<br>    fread(&frame, sizeof(frame), 1, fp);<br>    if (frame.frameType != FRAME_TYPE_HEADER)<br>    {<br>        AfxMessageBox("record file doesn't begin with header");<br>        return -1;<br>    }<br>    fread(&hdr, sizeof(hdr), 1, fp);<br>    GetDlgItem(IDC_DIM)->SetWindowText(format("%dx%d", hdr.width, hdr.height));<br>    GetDlgItem(IDC_CODEC_ID)->SetWindowText(format("%d", hdr.codecId));<br>    GetDlgItem(IDC_PIXEL_FORMAT)->SetWindowText(format("%d", hdr.pixelFormat));<br>    GetDlgItem(IDC_TIMEBASE)->SetWindowText(format("%d/%d", hdr.timebaseNum, hdr.timebaseDen));<br>    AVCodec *pCodec;<br><br>#if 0<br>#define CHECK(decoder)\<br>    pCodec = avcodec_find_decoder_by_name(#decoder);\<br>    AfxMessageBox(pCodec ? #decoder " found" : "can't find " #decoder);<br><br>    CHECK(h264_cuvid);<br><br>#undef CHECK<br>#endif<br><br>    pCodec = avcodec_find_decoder(AV_CODEC_ID_H264);<br>    //pCodec = avcodec_find_decoder_by_name("h264_cuvid");<br>    if (!pCodec)<br>    {<br>        AfxMessageBox("can't find h264 decoder");<br>        return -1;<br>    }<br><br>    AVCodecContext *pCodecContext = avcodec_alloc_context3(pCodec);<br>    if (!pCodecContext)<br>    {<br>        AfxMessageBox("can't allocate codec context");<br>        return -1;<br>    }<br><br>#if 0<br>// enumerating available codecs<br>    //av_register_all();<br>    avcodec_register_all();<br><br>    AVCodec *current_codec = av_codec_next(NULL);<br>    while (current_codec != NULL)<br>    {<br>        TRACE("%s\n", current_codec->name);<br>        current_codec = av_codec_next(current_codec);<br>    }<br>#endif<br><br>    int err = avcodec_open2(pCodecContext, pCodec, NULL);<br>    if (err != 0)<br>    {<br>        char buf[AV_ERROR_MAX_STRING_SIZE];<br>        av_make_error_string(buf, AV_ERROR_MAX_STRING_SIZE, err);<br>        char buf2[AV_ERROR_MAX_STRING_SIZE];<br>        sprintf(buf2, "%d (%x): %s\n", err, err, buf);<br>        AfxMessageBox(buf2);<br>        return -1;<br>    }<br>    AfxMessageBox("operation completed successfully");<br>    fclose(fp);<br>    return 0;<br>}<br><br></div></div></div>
</div></div>
</div></div>