Skip to main content

records multiple (background) windows using ctypes and ffmpeg - Windows only

pip install schirmshots

Tested against Windows 10 / Python 3.10 / Anaconda

Customizable Recording Parameters - The function allows you to specify various recording parameters, such as the
output video file path, the target window's handle (HWND), the window's position and dimensions,
whether to run in headless mode, desired frame rate, compression parameters, and more.
This level of customization gives you fine-grained control over the recording process.

Headless Mode - If the headless parameter is set to true, the function utilizes the FakeHeadless class to run in
headless mode. This means that it hides the window that is being recorded. This can be advantageous for automation and background tasks.

Hotkey Termination - The function supports a hotkey combination (killhotkey)
to terminate the recording process. This provides an easy and user-friendly way to stop the recording if needed.

Error Handling - The code includes error handling for various scenarios, such as removing an existing video
file before starting the recording and handling exceptions that might arise during the recording process.
This helps ensure a smoother execution even in the presence of unexpected issues.

Dynamic Window Resizing - The code includes functionality to dynamically resize the target window before recording,
which can be useful if you want to ensure a specific window size for the recording. If you resize the window,
the frames won't be recorded, and the window will automatically be resized to the dimensions from the beginning, and the recording
will go on. However, you can move the window during the recording

External Process Management - The code manages external processes, like launching a subprocess which starts a main
process (completely independent) for every recording
and ensuring it runs in the background. That means you can record multiple windows at once and use all your CPUs

Start recording video of a specific window using specified parameters.

Args:
	videofile (str): The path to the output video file.
	hwnd (int): The handle of the target window to be recorded.
	windowpos (tuple, optional): The position and dimensions of the window as a tuple (startx, starty, width, height).
		If None, the window's position and dimensions will not be altered before recording.
	headless (int | bool, optional): Set to 1 or True to run in headless mode (hides the window that is being recorded), 0 or False otherwise.
	framerate (int, optional): The approximate desired recording frame rate. Default is 0 (no specific framerate).
	params (tuple, optional): Additional parameters for video compression, as a tuple of tuples.
		Default is (("-vcodec", "libx264"), ("-crf", 0), ("-preset", "ultrafast")).
	killhotkey (str, optional): The hotkey combination to terminate the recording. Default is "ctrl+alt+e" - can be used multiple times.
	use_client (int | bool, optional): Set to 1 or True to use the client area of the window, 0 or False otherwise.

Returns:
	None

Example:
	from schirmshots import start_recording # needs to be in a file - not directly from the console - make sure that ffmpeg is installed

	start_recording(
		headless = 0,
		videofile= f'c:\\myvideofile2.mkv',
		windowpos=None,# (0,0,640,480),
		hwnd=3477668,
		framerate = 30,
		params = (("-vcodec", "libx264"), ("-crf", 0), ("-preset", "slow")),
		killhotkey='ctrl+alt+e',
	)

Metadata

Release files for schirmshots 0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schirmshots 0.10
File Size Uploaded Provenance Actions
schirmshots-0.10.tar.gz 12.8 kB Without provenance Details for schirmshots-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for schirmshots 0.10
File Interpreter ABI Platform Actions
schirmshots-0.10-py3-none-any.whl Python 3 none any Details for schirmshots-0.10-py3-none-any.whl

Total release size: 26.8 kB

Release files / schirmshots-0.10.tar.gz

Download URL schirmshots-0.10.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6eed9db25367878f0cbcdfe77c919c84ed92353b24c40b3cb1aaf926a980a052
BLAKE2b-256 checksum
How to use checksums
e80321c900a0fe7ae2edbd18c9128df699f09d9deb880f4d4555ac2bc0925442
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / schirmshots-0.10-py3-none-any.whl

Download URL schirmshots-0.10-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df2820f0455ec12cf28fc3fca7aa940d1ed5a69ec49290f201330443e59eeca6
BLAKE2b-256 checksum
How to use checksums
f1a22f021dd93147686a180cdf4bcd4d8287f27b8cb8686c494d417b501ba099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for schirmshots 0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page