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.

gproperty active: bool#
  • read-only

Whether recording is currently active.

gproperty is_paused: bool#
  • read-only

Whether recording is currently paused.

gproperty is_available: bool#
  • read-only

Whether gpu-screen-recorder is installed and available.

async start_recording(config: RecorderConfig) None#

Start recording. This function exits when recording ends.

Parameters:

config (RecorderConfig) -- The recorder configuration.

Raises:
Return type:

None

stop_recording() None#

Stop recording.

Return type:

None

pause_recording() None#

Pause recording. This has an effect only if the recording is active and not already paused.

Return type:

None

continue_recording() None#

Continue recording. This has an effect only if the recording is active and paused.

Return type:

None

list_capture_options() list[CaptureOption]#

List available capture options.

Return type:

list[CaptureOption]

Returns:

A list of available capture options.

Raises:
async list_capture_options_async() list[CaptureOption]#

Asynchronous version of list_capture_options().

Return type:

list[CaptureOption]

Returns:

A list of available capture options.

Raises:
list_audio_devices() list[AudioDevice]#

List audio devices.

Return type:

list[AudioDevice]

Returns:

A list of audio devices.

Raises:
async list_audio_devices_async() list[AudioDevice]#

Asynchronous version of list_audio_devices().

Return type:

list[AudioDevice]

Returns:

A list of audio devices.

Raises:
list_application_audio() list[ApplicationAudio]#

List applications that you can record audio from.

Return type:

list[ApplicationAudio]

Returns:

A list of applications that you can record audio from.

Raises:
async list_application_audio_async() list[ApplicationAudio]#

Asynchronous version of list_application_audio().

Return type:

list[ApplicationAudio]

Returns:

A list of applications that you can record audio from.

Raises:
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 by gpu-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".

path: str#

[-o] The output file path.

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 format WxH+X+Y.

framerate: int | None = None#

[-f] Frame rate to record at.

audio_devices: list[str] | None = None#

[-a] Audio device or application to record from (pulse audio device).

quality: Literal['medium', 'high', 'very_high', 'ultra'] | None = None#

[-q] Video quality.

video_codec: Literal['auto', 'h264', 'hevc', 'av1', 'vp8', 'vp9', 'hevc_hdr', 'av1_hdr', 'hevc_10bit', 'av1_10bit'] | None = None#

[-k] Video codec to use.

audio_codec: Literal['aac', 'opus', 'flac'] | None = None#

[-ac] Audio codec to use.

audio_bitrate: int | None = None#

[-ab] Audio bitrate in kbps.

framerate_mode: Literal['cfr', 'vfr', 'content'] | None = None#

[-fm] Framerate mode.

bitrate_mode: Literal['auto', 'qp', 'vbr', 'cbr'] | None = None#

[-bm] Bitrate mode.

color_range: Literal['limited', 'full'] | None = None#

[-cr] Color range.

cursor: Literal['yes', 'no'] | None = None#

[-cursor] Record cursor.

encoder: Literal['gpu', 'cpu'] | None = None#

[-encoder] Which device should be used for video encoding.

format_time: bool = True#

Whether to format the time in path.

extra_args: dict[str, str]#

Extra arguments to pass to gpu-screen-recorder.

classmethod new_from_options() RecorderConfig#

Create a RecorderConfig based on options (Recorder).

Return type:

RecorderConfig

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
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.

monitor_resolution: str | None = None#

The resolution of the monitor. None if option is not a monitor name.

class ignis.services.recorder.AudioDevice(device_name: str, human_readable_name: str) None#
device_name: str#

The name of the device (e.g., alsa_input.pci-0000_00_1f.3.analog-stereo). Can be passed to RecorderConfig.audio_devices.

human_readable_name: str#

The name of the device in a human-readable format (e.g., Built-in Audio Analog Stereo).

class ignis.services.recorder.ApplicationAudio(app: str) None#
app: str#

The application which plays audio.