QVideoWidget Example#

Basic Qt tutorial.

from __future__ import annotations

import sys

import numpy as np
from qtpy.QtGui import QColor
from qtpy.QtMultimediaWidgets import QVideoWidget
from qtpy.QtWidgets import QApplication

from qtvideo.providers import FrameProvider


app = QApplication(sys.argv)

qvideowidget = QVideoWidget()
qvideowidget.resize(640, 480)
qvideowidget.show()

frame_provider = FrameProvider()
frame_provider.video_sink = qvideowidget.videoSink()

color = QColor("royalblue")
np_frame = np.zeros((600, 600, 4), dtype=np.uint8)
r, g, b, a = color.getRgb()
np_frame[:, :] = (b, g, r, a)
frame_provider.write_frame(np_frame)
qvideowidget example

Out:

2022-04-18 05:50:12.463 | DEBUG    | qtvideo._qt:from_env:105 - Using from QT_API=pyqt6 environment variable.

True

Create a widget, populate it with a layout, then add a label with some text:

if __name__ == "__main__":
    app.exec()

Total running time of the script: ( 0 minutes 2.325 seconds)

Gallery generated by Sphinx-Gallery