Skip to main content

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

Project description

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',
	)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

schirmshots-0.10.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

schirmshots-0.10-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file schirmshots-0.10.tar.gz.

File metadata

  • Download URL: schirmshots-0.10.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for schirmshots-0.10.tar.gz
Algorithm Hash digest
SHA256 6eed9db25367878f0cbcdfe77c919c84ed92353b24c40b3cb1aaf926a980a052
MD5 5790949b79dccfc9339c7c7d71b1182f
BLAKE2b-256 e80321c900a0fe7ae2edbd18c9128df699f09d9deb880f4d4555ac2bc0925442

See more details on using hashes here.

File details

Details for the file schirmshots-0.10-py3-none-any.whl.

File metadata

  • Download URL: schirmshots-0.10-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for schirmshots-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 df2820f0455ec12cf28fc3fca7aa940d1ed5a69ec49290f201330443e59eeca6
MD5 1ef7678c96459cf54674c59f51567779
BLAKE2b-256 f1a22f021dd93147686a180cdf4bcd4d8287f27b8cb8686c494d417b501ba099

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page