octopus.capture.screen
- class octopus.capture.screen.ScreenCapture(device, output_dir, output_filename='screen.mp4')[source]
Bases:
AbstractCaptureScreenCapture handles screen recording on an Android device.
This class provides methods to start and stop screen recording and to retrieve the recorded file from the device.
- device
The Android device to capture from.
- output_filename
Name of the output file.
- output_path
Path to the output directory or file.
- start_capture_time
Timestamp when capture starts.
- end_capture_time
Timestamp when capture ends.
- __init__(device, output_dir, output_filename='screen.mp4')[source]
Initializes ScreenCapture with device and output settings.
- Parameters:
device (AndroidDevice) – Instance of
AndroidDevice.output_dir (Path) – Directory to store the output file.
output_filename (str | None) – Name of the output file (default: “screen.mp4”).
Sets up the output path and initializes capture timestamps.
- get_output_file()[source]
Returns the path to the output file.
- Returns:
The path to the screen recording file.
- Return type:
- get_result()[source]
Returns a dictionary with capture result details.
- Returns:
A dictionary containing the output file name, start and end capture times, and capture duration in milliseconds.
- Return type:
- start_capture()[source]
Starts screen recording on the Android device.
This method initiates the screen recording process using the screenrecord command via ADB. The start timestamp is recorded in milliseconds.
- Raises:
Exception – If the screen recording fails to start.
Notes
The command screenrecord limits the capture duration to 3 minutes.
- stop_capture()[source]
Stops screen recording and retrieves the recorded file.
This method sends a SIGINT to terminate the screen recording, waits for the process to finish, and then pulls the recorded file from the device. The end timestamp is recorded in milliseconds.
Handles exceptions during stopping and file retrieval.
- path_on_device = '/data/local/tmp/screen.mp4'
The file path on the device where the recording is stored.