opencv / opencv/opencv-python

ffmpeg video decode is not hardware accelerated on Windows

Abierto
#520 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
5.4k
Forks
1k
Merge medio
22 h 17 min
PR fusionados (30 d)
3

Descripción

Expected behaviour

ffmpeg/libavcodec video decoding should be hardware accelerated via D3D11.

Actual behaviour

ffmpeg/libavcodec video decoding is not hardware accelerated.

Steps to reproduce

cap = cv2.VideoCapture('file.mp4')
frame = True
while frame:
frame = cap.read()

Running on Windows 10 x64, Intel Core i7-3520M, Python 3.9, opencv-python 4.5.3.56.
The same test H264 file opened in VLC with D3D11 hardware acceleration via libavcodec at a similar decoding rate uses much less CPU.

Although hwaccels is no longer disabled in the ffmpeg build script (https://github.com/opencv/opencv_3rdparty/commit/7342d31a948774b2a56ccee9015ad36429762d9b#diff-6862fa01d6f0bc4c9601c1a0a9d170cb49cf255b25bfc66a02f958fa47be43a2), D3D11 support is not getting built in the Windows ffmpeg DLLs used with opencv-python.

I suspect the D3D11 headers and libraries need to be added for support to be enabled at the time of ffmpeg compile, and either need to be borrowed from VLC or compiled using MSVC which includes the headers in the Windows SDK, instead of MinGW or gcc cross-compile.

Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • I'm using the latest version of opencv-python

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza inspeccionando el script de compilación de ffmpeg en el commit opencv_3rdparty enlazado y el proceso que produce las DLL de ffmpeg para Windows. Comprueba cómo se proporcionan los encabezados y las bibliotecas de D3D11 durante la compilación y, después, reproduce la prueba VideoCapture de opencv-python en Windows. Se considera terminado cuando la decodificación por hardware D3D11 está habilitada en las DLL producidas y la prueba esperada utiliza menos CPU.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
build-system
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.