[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 22:50:49
Message-ID: CA+-0_dpBqZRH0ui=N1W+6oLCfk5L8vbGXJNjxDS=gSw+ME+biA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


[image: image.png]
I was able to use QWindowCapture to successfully capture some of the
windows. For example, in the screenshot above I've captured a Finder
window. It had to do with needing to call self.window_capture.start() again
after I've set a new window.

My goal is to capture my PyQt window itself which is generating animations,
but I'm not seeing the window listed as a capturable window in the
QWindowCapture.capturableWindows() list. Note that the PyQt window is
called "TESTING TESTING", and it's not in the list. I've checked all these
capturable windows, and none of them are the PyQt window. *Is it just not
possible to capture a PyQt window with QWindowCapture?*

0 - Item-0 - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f78b0>
1 - Sound - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f7290>
2 - Battery - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6f80>
3 - WiFi - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6490>
4 - BentoBox - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f65e0>
5 - Clock - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6650>
6 - CPU_mini - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6b90>
7 - RAM_memory - <PyQt6.QtMultimedia.QCapturableWindow object at
0x1034f6b20>
8 - Item-1 - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6c70>
9 - Item-0 - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6dc0>
10 - Menubar - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6e30>
11 - Dock - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6ff0>
12 - anim.py — anim - <PyQt6.QtMultimedia.QCapturableWindow object at
0x1034f6ea0>
13 - Window 0x33 - <PyQt6.QtMultimedia.QCapturableWindow object at
0x1034f70d0>
14 - Wallpaper- - <PyQt6.QtMultimedia.QCapturableWindow object at
0x1034f7220>
15 - Desktop - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f7370>
16 - Desktop - <PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f7680>

On Thu, Feb 22, 2024 at 2:37 PM Jason Hallen <hallenj@gmail.com> wrote:

> 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><img src="cid:ii_lsxsw8o62" alt="image.png" width="578" \
height="362"><br></div><div>I was able to use QWindowCapture to successfully capture \
some of the windows. For example, in the screenshot above I&#39;ve captured a Finder \
window. It had to do with needing to call self.window_capture.start() again after \
I&#39;ve set a new window.</div><div><br></div><div>My goal is to capture my PyQt \
window itself which is generating animations, but I&#39;m not seeing the window \
listed as a capturable window in the QWindowCapture.capturableWindows() list. Note \
that the PyQt window is called &quot;TESTING TESTING&quot;, and it&#39;s not in the \
list. I&#39;ve checked all these capturable windows, and none of them are the PyQt \
window. <b>Is it just not possible to capture a PyQt window with \
QWindowCapture?</b><br></div><div><br></div><div>0 - Item-0 - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f78b0&gt;<br>1 - Sound - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f7290&gt;<br>2 - Battery - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6f80&gt;<br>3 - WiFi - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6490&gt;<br>4 - BentoBox - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f65e0&gt;<br>5 - Clock - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6650&gt;<br>6 - CPU_mini - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6b90&gt;<br>7 - RAM_memory \
- &lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6b20&gt;<br>8 - Item-1 - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6c70&gt;<br>9 - Item-0 - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6dc0&gt;<br>10 - Menubar - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6e30&gt;<br>11 - Dock - \
&lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6ff0&gt;<br>12 - anim.py \
— anim - &lt;PyQt6.QtMultimedia.QCapturableWindow object at 0x1034f6ea0&gt;<br>13 - \
Window 0x33 - &lt;PyQt6.QtMultimedia.QCapturableWindow object at \
0x1034f70d0&gt;<br>14 - Wallpaper- - &lt;PyQt6.QtMultimedia.QCapturableWindow object \
at 0x1034f7220&gt;<br>15 - Desktop - &lt;PyQt6.QtMultimedia.QCapturableWindow object \
at 0x1034f7370&gt;<br>16 - Desktop - &lt;PyQt6.QtMultimedia.QCapturableWindow object \
at 0x1034f7680&gt;</div></div><br><div class="gmail_quote"><div dir="ltr" \
class="gmail_attr">On Thu, Feb 22, 2024 at 2:37 PM Jason Hallen &lt;<a \
href="mailto:hallenj@gmail.com">hallenj@gmail.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"><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" \
target="_blank">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>
</blockquote></div>


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

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

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