Failed to execute: 0x80070057, when decoding video via ffmpeg with dxva2

半腔热情 提交于 2019-11-30 12:12:26

I finally found out what my issue was. After calling avcodec_decode_video2, I was not updating the size and data pointer of the packet like this:

int r = avcodec_decode_video2(_codecContext, frame, &frameDecoded, &pkt);
pkt.size -= r;
pkt.data += r;

Now, the video is properly decoded and I have no artifacts anymore.

Also, regarding the lag, I believe this was a separate issue, non related to the error messages, and due to the time that it takes to copy the image back to the CPU's memory. If you need to do this, instead of using av_image_copy_plane like in the code that I posted with my question above, you may want to look at what VLC does, or at this link https://software.intel.com/en-us/articles/copying-accelerated-video-decode-frame-buffers. I did a quick test on my machine and it reduced the time by a factor of 7 or 8.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!