#!/usr/bin/env python3 """Make a CI screen recording navigable, without shortening it. The recording covers the whole job including early boot, which is exactly what you want when triaging and exactly what makes it tedious to scrub. This adds: - chapters, one per test, titled with the test's outcome - a soft subtitle track, one cue per marked moment Matroska carries both natively and mpv/VLC navigate chapters out of the box, so this is a single `-c copy` remux: no re-encode, nothing burned into the picture, and the original stays playable in anything that ignores the extras. Timestamps come from the markers file written by etchdroid.utils.mark during the test run, which records wall-clock epochs. The recording's own t=0 is whenever ffmpeg started, which qemu-kvm-action reports; subtracting gives offsets into the video. annotate-recording.py [-o out.mkv] Missing inputs are not an error: the recording is a debugging aid, so a job that produced no markers should still upload its video. """ import argparse import os import subprocess import sys import tempfile from pathlib import Path # Outcome words pytest reports, used to fold "PASSED test_foo" events into the chapter title for # test_foo so a failure is findable from the chapter list alone. OUTCOMES = ("PASSED", "FAILED", "SKIPPED", "ERROR", "XFAILED", "XPASSED") def parse_markers(text: str) -> list[tuple[float, str, str]]: """Parse `\t\t