enthought / pyface

pyface: traits-capable windowing framework
Other
105 stars 55 forks source link

Bug report: Cannot import QAbstractVideoBuffer #1131

Closed sallenEnth closed 2 years ago

sallenEnth commented 2 years ago

Environment

OS: Linux (Kubuntu 20.04, a similar issue was observed on Ubuntu 18) Python version: 3.6/3.8 Toolkit: Qt Qt API: PyQt5/PyQt6/PySide2/PySide6

Description

With Python 3.6 I am not able to display a video through traitsui's VideoEditor. I switched to Python 3.8, I only managed to make it work when using PyQt5 API. I tried with PyQt6, PySide2, PySide6 but with each of these I get the following error message

File "/home/sallen/.edm/envs/traitsui/lib/python3.8/site-packages/traitsui/qt4/video_editor.py", line 14, in <module>
    from pyface.qt.QtMultimedia import (
ImportError: cannot import name 'QAbstractVideoBuffer' from 'pyface.qt.QtMultimedia' (/home/sallen/.edm/envs/traitsui/lib/python3.8/site-packages/pyface/qt/QtMultimedia.py)

Note that with PySide6 I tried adding the Pyside6_Addons but to no avail.

Steps to Reproduce

It can be tested with traitsui's VideoEditor_demo.py I wonder if I should have open the issue on traitsui, but because of the error message, it seems more appropriate here.

corranwebster commented 2 years ago

It looks like QAbstractVideoBuffer has been removed in Qt6:

The back-end API of Qt Multimedia is private in Qt 6. This improves response time for supporting new multimedia use cases. Any classes that contain the words "Control" or "Abstract" in the class name in Qt 5 are now private in Qt 6.

This likely means that the TraitsUI video editor may need a significant refactor.

corranwebster commented 2 years ago

PySide2 should still work. @sallenEnth can you tell me what happens when you run:

from PySide2.QtMultimedia import QAbstractVideoBuffer
sallenEnth commented 2 years ago

@corranwebster when I run the VideoEditor_demo.py from traitsui repository with Pyside2 backend I get the following message in my terminal:

defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"

At the bottom of the UI window I can see the following message:

State: playing Status: unknown Buffer: 0 Error: The QMediaPlayer object does not have a valid service

But when I use an environment with PyQt5 I am able to play the video.

When I run:

from PySide2.QtMultimedia import QAbstractVideoBuffer

it completes successfully.

corranwebster commented 2 years ago

This is a TraitsUI bug - the QtMultimedia API has changed significantly in Qt6 and in particular QAbstractVideoBuffer is no longer part of the public API.

See this issue and a possible fix.