PySide6.QtMultimedia.QWindowCapture¶
- class QWindowCapture¶
This class is used for capturing a window. More…
Added in version 6.6.
Synopsis¶
Properties¶
activeᅟ- Whether the capturing is currently activeerrorᅟ- The code of the last errorerrorStringᅟ- Human readable string describing the cause of errormaximumFrameRateᅟ- Window capture frame rate upper limitwindowᅟ- The window for capturing
Methods¶
def
__init__()def
captureSession()def
error()def
errorString()def
isActive()def
setWindow()def
window()
Slots¶
def
setActive()def
start()def
stop()
Signals¶
def
activeChanged()def
errorChanged()def
errorOccurred()def
windowChanged()
Static functions¶
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
The class captures a window. It is managed by the
QMediaCaptureSessionclass where the captured window can be displayed in a video preview object or recorded to a file.The following snippet shows how to select one of the capturable windows and display the result in a
QVideoWidget:session = QMediaCaptureSession() windowCapture = QWindowCapture() session.setWindowCapture(windowCapture) videoWidget = QVideoWidget() session.setVideoOutput(videoWidget) videoWidget.show() # A window must be selected before capturing can start. windows = QWindowCapture.capturableWindows() if not windows.isEmpty(): windowCapture.setWindow(windows.first()) windowCapture.start()
Window Capture Limitations¶
The following limitations apply to using
QWindowCapture:QWindowCaptureis only supported with the FFmpeg backend.On some platforms, no new video frames are emitted while the captured window content remains unchanged. Applications should therefore not rely on receiving a continuous stream of frames at the requested frame rate.
The following limitations apply when using
QWindowCaptureon X11 systems:On Linux X11 systems, when a window is moved partially outside the visible screen area, only the visible region is captured. As a result, the emitted video frames may have a size smaller than the window’s geometry.
Windows that are outside the visible screen area cannot be captured, and an error signal is emitted in that case.
The behavior of minimized windows or those located on an invisible virtual workspace depends on the window manager. For example, such windows can be captured on GNOME, whereas on WindowMaker or Xfwm such capturing is not allowed, and the window capture instance emits an error.
See also
- class Error¶
Enumerates error codes that can be signaled by the
QWindowCaptureclass.errorString()provides detailed information about the error cause.Constant
Description
QWindowCapture.Error.NoError
No error
QWindowCapture.Error.InternalError
Internal window capturing driver error
QWindowCapture.Error.CapturingNotSupported
Window capturing is not supported
QWindowCapture.Error.CaptureFailed
Capturing window failed
QWindowCapture.Error.NotFound
Selected window not found
Note
Properties can be used directly when
from __feature__ import true_propertyis used or via accessor functions otherwise.- property activeᅟ: bool¶
This property holds whether the capturing is currently active..
- Access functions:
Signal
activeChanged()
- property errorᅟ: QWindowCapture.Error¶
This property holds the code of the last error..
- Access functions:
Signal
errorChanged()
- property errorStringᅟ: str¶
This property holds a human readable string describing the cause of error..
- Access functions:
Signal
errorChanged()
- property maximumFrameRateᅟ: std::optional<qreal>¶
This property holds The window capture frame rate upper limit..
This can be set to override the capture frame rate used by default based on e.g. display refresh rate, but only as an upper limit since window capture produces frames at a variable rate. Setting this higher than the display refresh rate is not recommended and can cause errors.
Any changes to this property are applied the next time the
QWindowCapturegoes active.- Access functions:
- property windowᅟ: QCapturableWindow¶
This property holds the window for capturing..
Setting this property to an invalid window on an active
QWindowCapturewill cause it to go inactive and emit an error.See also
- Access functions:
Signal
windowChanged()
Constructs a new
QWindowCaptureobject withparent.- activeChanged(arg__1)¶
- Parameters:
arg__1 – bool
Notification signal of property
activeᅟ.- static capturableWindows()¶
- Return type:
.list of QCapturableWindow
Returns a list of
QCapturableWindowobjects that are currently available for capturing.Note
On macOS, invoking this method will trigger the “Screen Recording” permission dialog. If permissions have not yet been granted, this method will return an empty list. Invoking it multiple times will bring this dialog to the foreground.
- captureSession()¶
- Return type:
Returns the capture session this
QWindowCaptureis connected to.Use
setWindowCapture()to connect the window capture to a session.Getter of property
errorᅟ.- errorChanged()¶
This signal is emitted when the
error()orerrorString()properties are changed.This signal is not emitted whenever multiple identical errors are raised. To track such errors, use the signal
errorOccurred().Notification signal of property
errorᅟ.Signals when an
erroroccurs, along with theerrorString.- errorString()¶
- Return type:
str
Getter of property
errorStringᅟ.- isActive()¶
- Return type:
bool
Getter of property
activeᅟ.- maximumFrameRate()¶
- Return type:
~std::optional
See also
Getter of property
maximumFrameRateᅟ.- maximumFrameRateChanged()¶
Notification signal of property
maximumFrameRateᅟ.- setActive(active)¶
- Parameters:
active – bool
See also
Setter of property
activeᅟ.- setMaximumFrameRate(frameRate)¶
- Parameters:
frameRate –
~std::optional
See also
Setter of property
maximumFrameRateᅟ.- setWindow(window)¶
- Parameters:
window –
QCapturableWindow
See also
Setter of property
windowᅟ.- start()¶
Starts capturing the
window().This is equivalent to setting the
active()property to true.- stop()¶
Stops capturing.
This is equivalent to setting the
active()property to false.- window()¶
- Return type:
See also
Getter of property
windowᅟ.- windowChanged(window)¶
- Parameters:
window –
QCapturableWindow
Notification signal of property
windowᅟ.