Reputation: 51
I've made a player for IP camera (fullHD H264) with FFMPEG I code under windows with Qt.I need the lowest latency as possible and the best result I can get is done whith :
But with "slow" CPU I have lot of latency if the bitrate is too high or it can't handle 1080p.
I really want to try hardware acceleration with DXVA2 to see if I can get better performance especially in slowest CPU.
But i really don't know how to proceed. I have to build FFMPEG with --enable-dxva2 and --enable-hwaccel=h264_dxva2 ? or Zeranoe build I have never use Direct X, do I need Direct X knowledge, or ffmpeg with --enable-dxva2 and --enable-hwaccel=h264_dxva2 care of everything ?
Thank you
Edit :
Hello, I use this post to help me in my HW acceleration with FFMPEG Failed to execute: 0x80070057, when decoding video via ffmpeg with dxva2
I decode the packet with
avcodec_decode_video2(pCodecCtx, pFrame, &gotPic, &packet);
and I'm getting my decoded frame with
dxva2_retrieve_data_call(pCodecCtx, pFrame, &gotPic, &packet);
I tried to convert it
sws_scale(img_convert_affic, pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize);
and copy the buffer to a Qimage
LastFrame=QImage(w,h,QImage::Format_RGB888);
for(int y=0;y<h;y++)
memcpy(LastFrame.scanLine(y),pFrameRGB->data[0]+y*pFrameRGB->linesize[0],w*3);
I got my picture but with lot of artefact and after few seconds I got a segmentation fault in dxva2_retrieve_data_call(pCodecCtx, pFrame, &gotPic, &packet);
Edit : Problem solved i didn't check if I got a picture before retreiving it. But the performance are very poor on my desktop cmputer (intel core i5 650, 4GB RAM, ATI HD5800) it consumes 5% more of CPU, 3 times more RAM, and lot of corrupt frame. It's better on a newer computer, but soft decoder is better. dxva2_retrieve_data_call and sws_swale consume lot of time when hwaccel is enabled ...
Is there a way to display NV12 picture in Qt (no sws_scale conversion) and there is a way to optimise dxva_retrieve_data_call ?
Upvotes: 1
Views: 6465
Reputation: 1515
If you want real GPU acceleration (no copy back), you need to provide DirectX Surface through IDirect3DDeviceManager9(Directx9)/IMFDXGIDeviceManager(Directx11). QT and FFMPEG does not provide it for you. You will also need to provide the DirectX display mechanism.
Upvotes: 1