[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: PyQt6 and QWindowCapture
From:       Jason Hallen <hallenj () gmail ! com>
Date:       2024-02-22 20:37:06
Message-ID: CA+-0_dpFv=LEKuhaw=mOvgErjxkDQQikrRfwnJtJbyPe1-No-g () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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
>

[Attachment #5 (text/html)]

<div dir="ltr"><div><div>Wonderful, thank you! I upgraded to v6.6 and I now have access to \
QWindowCapture.</div><div><br></div><div>However, I&#39;m having trouble recording any windows. \
I must be missing something. Here&#39;s my code where I&#39;m trying to capture my VS Code \
window.<br></div><div><br></div><div>self.window_capture = \
QWindowCapture(self)</div>self.window_capture.setWindow(QWindowCapture.capturableWindows()[13]) \
# VS Code window<br></div><div>self.window_capture.start()<br></div><div>self.media_capture_session \
= QMediaCaptureSession()</div><div>self.media_capture_session.setWindowCapture(self.window_capture)</div><div>self._video_widget \
= QVideoWidget(self)<br>self._video_widget.resize(400, \
300)<br>self.media_capture_session.setVideoOutput(self._video_widget)</div><div><br></div><div>When \
I run this I don&#39;t see anything in the video widget. Here&#39;s a \
screenshot.</div><div><br></div><div><img src="cid:ii_lsxolp560" alt="Screenshot 2024-02-22 at \
2.34.04 PM.png" width="578" height="291"></div><div><br></div><div>When I instead use \
QScreenCapture in the MediaCaptureSession I see the video feed.</div><div><br></div><div><img \
src="cid:ii_lsxonnt91" alt="Screenshot 2024-02-22 at 2.35.37 PM.png" width="578" \
height="291"></div><div><br></div><div>Can someone help me properly connect a window \
capture?</div><div><br></div><div>Thanks,</div><div>Jason<br></div><div><br></div><div><br></div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 22, 2024 at 10:49 AM Phil \
Thompson &lt;<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px \
solid rgb(204,204,204);padding-left:1ex">On 22/02/2024 16:41, Jason Hallen wrote:<br> &gt; \
That&#39;s great to hear. I wonder what&#39;s going wrong for me then. When<br> &gt; importing \
the class I get this error:<br> &gt; <br>
&gt; ImportError: cannot import name &#39;QWindowCapture&#39; from <br>
&gt; &#39;PyQt6.QtMultimedia&#39;<br>
&gt; (/Users/hallenj/miniconda3/envs/csound/lib/python3.11/site-packages/PyQt6/<br>
&gt; <a href="http://QtMultimedia.abi3.so" rel="noreferrer" \
target="_blank">QtMultimedia.abi3.so</a>)<br> &gt; <br>
&gt; I&#39;ve got the 6.5.1 version. Is there a different version or a <br>
&gt; particular<br>
&gt; distribution of PyQt6 I should be using?<br>
<br>
As QWindowCapture was added to Qt v6.6 then you need PyQt v6.6 at least.<br>
<br>
Phil<br>
</blockquote></div>


["=?UTF-8?B?U2NyZWVuc2hvdCAyMDI0LTAyLTIyIGF0IDIuMzQuMDQ=?=
	=?UTF-8?B?4oCvUE0ucG5n?=" (image/png)]
["=?UTF-8?B?U2NyZWVuc2hvdCAyMDI0LTAyLTIyIGF0IDIuMzUuMzc=?=
	=?UTF-8?B?4oCvUE0ucG5n?=" (image/png)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic