opencv / opencv/opencv-python

ffmpeg video decode is not hardware accelerated on Windows

Aperta
#520 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
5.4k
Fork
1k
Merge medio
22h 17m
PR unite (30g)
3

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando lo script di compilazione di ffmpeg nel commit opencv_3rdparty collegato e il processo che produce le DLL ffmpeg per Windows. Verifica come vengono forniti gli header e le librerie D3D11 durante la compilazione, quindi riproduci il test VideoCapture di opencv-python su Windows. Il lavoro è completato quando la decodifica hardware D3D11 è abilitata nelle DLL prodotte e il test previsto utilizza meno CPU.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
build-system
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.