-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Hardware Accelerated Decoding
Install vainfo libva-dev, libva-intel-vaapi-driver(intel gpu), xvba-va-driver(ATI), vdpau-va-driver(NVIDIA)
If vainfo works, then QtAV should work with VA-API
Since Qt5.5, you can enable EGL by setting environment var QT_XCB_GL_INTEGRATION=xcb_egl
. player
and QMLPlayer
have EGL configuration too. If EGL is used, VA-API decoding and OpenGL rendering can get the best performance. NVIDIA GPUs currently do not support EGL+VA-API. AMD is not tested.
If EGL is used, you can use zero copy for X11, DRM display. Otherwise, zero copy is only available for X11 and GLX display.
OpenGL desktop mode supports 0-copy. To use 0-copy, make sure your program runs with NVIDIA GPU (on Optimus). DirectCopy
is the default. DirectCopy
mode is fast enough, faster than potplayer, lavfilters+mpc, and may be the fastest one. ZeroCopy
mode is even faster.
nvidia-331 worked. I don't know how to enable CUDA for other drivers. Tell me if you know.
Install latest nvidia driver.
Run in OpenGL ES2 mode (ANGLE) to enable 0-copy. 0-copy in OpenGL desktop mode only supports some new intel GPUs in my tests, maybe also supports AMD.
CUDA:
QVaraiantHash cuda_opt;
cuda_opt["surfaces"] = 0; //key is property name, case sensitive
cuda_opt["copyMode"] = "ZeroCopy"; // default is "DirectCopy"
QVariantHash opt;
opt["CUDA"] = cuda_opt; //key is decoder name, case sensitive
player.setOptionsForVideoCodec(opt);
Since QtAV1.8, CUDA decoder supports ZeroCopy. Run your program with NVIDIA GPU if you have multiple GPUs.
VA-API:
QVaraiantHash va_opt;
va_opt["display"] = "X11"; //"GLX", "X11", "DRM"
va_opt["copyMode"] = "ZeroCopy"; // "ZeroCopy", "OptimizedCopy", "GenericCopy". Default is "ZeroCopy" if possible
QVariantHash opt;
opt["VAAPI"] = va_opt; //key is decoder name, case sensitive
player.setOptionsForVideoCodec(opt);
Copy mode for GPU decoders was introduced since 1.5.0. Copy mode can be ZeroCopy
, LazyCopy
, OptimizedCopy
and GenericCopy
.
- ZeroCopy: No data read back from GPU. Directly render the decoded data on GPU. It's the most efficient way. Now it's supported by
- CUDA
- VA-API with libva-x11 and libva-glx. It may not work for vdpau backend.
- VDA(OSX), VideoToolbox(OSX, iOS>=8)
- DXVA with ANGLE. (Desktop OpenGL is not stable now)
- LazyCopy: Used in VDA and VideoToolBox
- OptimizedCopy: Use SSE4.1 for x86 used by DXVA and VA-API(VDA crashes), and NEON for CedarV. SSE4.1 does not work for some GPUs, e.g. NVIDIA GS8400
- GenericCopy: Use memcpy
- D3D11
- Copy
- EGL (D3D11)
- DXVA
- Copy
- EGL (D3D9)
- OpenGL (WIP)
- CUDA
- Copy
- EGL (WIP)
- OpenGL
- VA-API
- Copy
- EGL DMA/DRM
- EGL TFP
- GLX TFP
- VDA
- Copy
- OpenGL
- VideoToolbox
- OSX Copy/0-Copy
- iOS Copy/0-Copy
- VDPAU
- OMX