opencv / opencv/opencv-python

ffmpeg video decode is not hardware accelerated on Windows

Offen
#520 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
5.4k
Forks
1k
Ø Merge
22 Std. 17 Min.
Gemergte PRs (30 T.)
3

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Untersuchung des ffmpeg-Build-Skripts beim verlinkten opencv_3rdparty-Commit und des Prozesses, der die Windows-ffmpeg-DLLs erzeugt. Prüfe, wie D3D11-Header und -Bibliotheken während der Kompilierung bereitgestellt werden, und reproduziere anschließend den opencv-python VideoCapture-Test unter Windows. Als erledigt gilt die Aufgabe, wenn D3D11-Hardware-Decoding in den erzeugten DLLs aktiviert ist und der erwartete Test weniger CPU verwendet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
build-system
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.