PyQt6 and QWindowCapture

Jason Hallen hallenj at gmail.com
Thu Feb 22 20:37:06 GMT 2024


Wonderful, thank you! I upgraded to v6.6 and I now have access to
QWindowCapture.

However, I'm having trouble recording any windows. I must be missing
something. Here's my code where I'm trying to capture my VS Code window.

self.window_capture = QWindowCapture(self)
self.window_capture.setWindow(QWindowCapture.capturableWindows()[13])   #
VS Code window
self.window_capture.start()
self.media_capture_session = QMediaCaptureSession()
self.media_capture_session.setWindowCapture(self.window_capture)
self._video_widget = QVideoWidget(self)
self._video_widget.resize(400, 300)
self.media_capture_session.setVideoOutput(self._video_widget)

When I run this I don't see anything in the video widget. Here's a
screenshot.

[image: Screenshot 2024-02-22 at 2.34.04 PM.png]

When I instead use QScreenCapture in the MediaCaptureSession I see the
video feed.

[image: Screenshot 2024-02-22 at 2.35.37 PM.png]

Can someone help me properly connect a window capture?

Thanks,
Jason



On Thu, Feb 22, 2024 at 10:49 AM Phil Thompson <phil at riverbankcomputing.com>
wrote:

> On 22/02/2024 16:41, Jason Hallen wrote:
> > That's great to hear. I wonder what's going wrong for me then. When
> > importing the class I get this error:
> >
> > ImportError: cannot import name 'QWindowCapture' from
> > 'PyQt6.QtMultimedia'
> >
> (/Users/hallenj/miniconda3/envs/csound/lib/python3.11/site-packages/PyQt6/
> > QtMultimedia.abi3.so)
> >
> > I've got the 6.5.1 version. Is there a different version or a
> > particular
> > distribution of PyQt6 I should be using?
>
> As QWindowCapture was added to Qt v6.6 then you need PyQt v6.6 at least.
>
> Phil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240222/89fd3160/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2024-02-22 at 2.34.04?PM.png
Type: image/png
Size: 49057 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240222/89fd3160/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2024-02-22 at 2.35.37?PM.png
Type: image/png
Size: 75121 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240222/89fd3160/attachment-0003.png>


More information about the PyQt mailing list