Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions openadapt_capture/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,34 @@ def audio_path(self) -> Path | None:
audio_path = self.capture_dir / "audio.flac"
return audio_path if audio_path.exists() else None

@property
def pixel_ratio(self) -> float:
"""Display pixel ratio (physical/logical), e.g. 2.0 for Retina.

Defaults to 1.0 if not stored in the recording.
"""
# Check if the Recording model has a pixel_ratio column
ratio = getattr(self._recording, "pixel_ratio", None)
if ratio is not None:
return float(ratio)
# Check the config JSON for pixel_ratio
config = getattr(self._recording, "config", None)
if isinstance(config, dict) and "pixel_ratio" in config:
return float(config["pixel_ratio"])
return 1.0

@property
def audio_start_time(self) -> float | None:
"""Start timestamp of the audio recording, or None if unavailable."""
# Check the AudioInfo relationship for the timestamp
audio_infos = getattr(self._recording, "audio_info", None)
if audio_infos:
first = audio_infos[0] if isinstance(audio_infos, list) else audio_infos
ts = getattr(first, "timestamp", None)
if ts is not None:
return float(ts)
return None

def raw_events(self) -> list[PydanticActionEvent]:
"""Get all raw action events (unprocessed).

Expand Down
3 changes: 3 additions & 0 deletions openadapt_capture/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def record(
video: bool = True,
audio: bool = False,
images: bool = False,
send_profile: bool = False,
) -> None:
"""Record GUI interactions.

Expand All @@ -26,6 +27,7 @@ def record(
video: Capture video (default: True).
audio: Capture audio (default: False).
images: Save screenshots as PNGs (default: False).
send_profile: Send profiling data via wormhole after recording (default: False).
"""
import time

Expand All @@ -43,6 +45,7 @@ def record(
capture_video=video,
capture_audio=audio,
capture_images=images,
send_profile=send_profile,
) as recorder:
recorder.wait_for_ready()
try:
Expand Down
6 changes: 5 additions & 1 deletion openadapt_capture/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
from collections import defaultdict
from itertools import cycle

import matplotlib.pyplot as plt
import matplotlib

matplotlib.use("Agg") # non-interactive backend; works from any thread

import matplotlib.pyplot as plt # noqa: E402
from loguru import logger

from openadapt_capture.db import models
Expand Down
Loading