Recorder#
- class ignis.services.recorder.RecorderService(*args: Any, **kwargs: Any)#
A screen recorder. Uses
gpu-screen-recorder
as the backend.There are options available for this service:
Recorder
.Example usage:
import asyncio from ignis.services.recorder import RecorderService, RecorderConfig recorder = RecorderService.get_default() # You can create a configuration from the options rec_config = RecorderConfig.new_from_options() # You can override them for this config rec_config.cursor = False # Manual creation of configuration rec_config = RecorderConfig( source="portal", # You can also pass a monitor name here path="path/to/file", # only source and path are required btw # arguments below are optional video_codec="h264", framerate=144, cursor=True, # "default_input" for microphone # "default_output" for internal audio # "default_output|default_input" for both audio_devices=["default_output"], # and a lot more... ) # Start recording asyncio.create_task(recorder.start_recording(config=rec_config)) # Stop recording recorder.stop_recording() # Pause recording recorder.pause_recording() # Continue recording recorder.continue_recording() # You can list available capture options (sources) print(recorder.list_capture_options()) # And audio devices print(recorder.list_audio_devices())
- signal recording_started#
Emitted when recording starts.
- signal recording_stopped#
Emitted when recording stops.
- async start_recording(config: RecorderConfig) None #
Start recording. This function exits when recording ends.
- Parameters:
config (
RecorderConfig
) -- The recorder configuration.- Raises:
GpuScreenRecorderError -- If an error occurs during recording.
GpuScreenRecorderNotFoundError -- If
gpu-screen-recorder
is not found.RecorderPortalCaptureCanceled -- If the user cancels the desktop portal capture (when
RecorderConfig.source
is set to"portal"
).
- Return type:
- pause_recording() None #
Pause recording. This has an effect only if the recording is active and not already paused.
- Return type:
- continue_recording() None #
Continue recording. This has an effect only if the recording is active and paused.
- Return type:
- list_capture_options() list[CaptureOption] #
List available capture options.
- Return type:
- Returns:
A list of available capture options.
- Raises:
GpuScreenRecorderError -- If
gpu-screen-recorder
exits with an error.GpuScreenRecorderNotFoundError -- If
gpu-screen-recorder
is not found.
- async list_capture_options_async() list[CaptureOption] #
Asynchronous version of
list_capture_options()
.- Return type:
- Returns:
A list of available capture options.
- Raises:
GpuScreenRecorderError -- If
gpu-screen-recorder
exits with an error.GpuScreenRecorderNotFoundError -- If
gpu-screen-recorder
is not found.
- list_audio_devices() list[AudioDevice] #
List audio devices.
- Return type:
- Returns:
A list of audio devices.
- Raises:
GpuScreenRecorderError -- If
gpu-screen-recorder
exits with an error.GpuScreenRecorderNotFoundError -- If
gpu-screen-recorder
is not found.
- async list_audio_devices_async() list[AudioDevice] #
Asynchronous version of
list_audio_devices()
.- Return type:
- Returns:
A list of audio devices.
- Raises:
GpuScreenRecorderError -- If
gpu-screen-recorder
exits with an error.GpuScreenRecorderNotFoundError -- If
gpu-screen-recorder
is not found.
- list_application_audio() list[ApplicationAudio] #
List applications that you can record audio from.
- Return type:
- Returns:
A list of applications that you can record audio from.
- Raises:
GpuScreenRecorderError -- If
gpu-screen-recorder
exits with an error.GpuScreenRecorderNotFoundError -- If
gpu-screen-recorder
is not found.
- async list_application_audio_async() list[ApplicationAudio] #
Asynchronous version of
list_application_audio()
.- Return type:
- Returns:
A list of applications that you can record audio from.
- Raises:
GpuScreenRecorderError -- If
gpu-screen-recorder
exits with an error.GpuScreenRecorderNotFoundError -- If
gpu-screen-recorder
is not found.
- class ignis.services.recorder.RecorderConfig(source: ~typing.Literal['screen', 'screen-direct', 'focused', 'portal', 'region'] | str, path: str, resolution_limit: str | None = None, region: str | None = None, framerate: int | None = None, audio_devices: list[str] | None = None, quality: ~typing.Literal['medium', 'high', 'very_high', 'ultra'] | None = None, video_codec: ~typing.Literal['auto', 'h264', 'hevc', 'av1', 'vp8', 'vp9', 'hevc_hdr', 'av1_hdr', 'hevc_10bit', 'av1_10bit'] | None = None, audio_codec: ~typing.Literal['aac', 'opus', 'flac'] | None = None, audio_bitrate: int | None = None, framerate_mode: ~typing.Literal['cfr', 'vfr', 'content'] | None = None, bitrate_mode: ~typing.Literal['auto', 'qp', 'vbr', 'cbr'] | None = None, color_range: ~typing.Literal['limited', 'full'] | None = None, cursor: ~typing.Literal['yes', 'no'] | None = None, encoder: ~typing.Literal['gpu', 'cpu'] | None = None, format_time: bool = True, extra_args: dict[str, str] = <factory>) None #
This documentation describes the arguments only briefly. All of them correspond to the arguments of
gpu-screen-recorder
.Run
gpu-screen-recorder --help
to get more detailed information about each argument.Most of the arguments default to
None
, which means their value will be automatically determined bygpu-screen-recorder
.-
source:
Literal
['screen'
,'screen-direct'
,'focused'
,'portal'
,'region'
] |str
# [
-w
] Window id to record, a display (monitor name), "screen", "screen-direct", "focused", "portal" or "region".
-
resolution_limit:
str
|None
= None# [
-s
] The output resolution limit of the video in the format WxH, for example 1920x1080.
-
region:
str
|None
= None# [
-region
] The region to capture, only to be used with -w region. This is in formatWxH+X+Y
.
-
audio_devices:
list
[str
] |None
= None# [
-a
] Audio device or application to record from (pulse audio device).
-
video_codec:
Literal
['auto'
,'h264'
,'hevc'
,'av1'
,'vp8'
,'vp9'
,'hevc_hdr'
,'av1_hdr'
,'hevc_10bit'
,'av1_10bit'
] |None
= None# [
-k
] Video codec to use.
-
encoder:
Literal
['gpu'
,'cpu'
] |None
= None# [
-encoder
] Which device should be used for video encoding.
- classmethod new_from_options() RecorderConfig #
Create a
RecorderConfig
based on options (Recorder
).- Return type:
- Returns:
An instance of
RecorderConfig
with data from options.
Hint
You can override an attribute value without changing the options:
rec_config = RecorderConfig.new_from_options() rec_config.cursor = "no" rec_config.source = "screen" # ... etc
-
source:
- class ignis.services.recorder.CaptureOption(option: Literal['screen', 'screen-direct', 'focused', 'portal', 'region'] | str, monitor_resolution: str | None = None) None #
-
option:
Literal
['screen'
,'screen-direct'
,'focused'
,'portal'
,'region'
] |str
# The name of the option. Can be passed to
RecorderConfig.source
.
-
option: