annotate

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package annotate draws on a finished screen recording what a person watching it needs to follow the run (`tb test --record --annotate`): a ring where each tap, double tap and long press landed (a ring that moves along a swipe), and, in a band added below the recording, the step that is running. The band keeps the text off the app's screen, so it hides nothing.

tb draws the text itself (captionImage, with the Go fonts) and ffmpeg only places the images: the video needs no subtitle support from ffmpeg (libass, freetype), which builds such as Homebrew's may not have.

The device records the screen as it is; tb's own taps and swipes are not drawn there (iOS and Chrome have no setting for that, and Android's "show taps" draws a dot too small and brief to see in a video). So tb draws them afterwards with ffmpeg, from what the runner noted while it ran, the same on every platform. Burning them in, rather than a subtitle track beside the video, is what keeps them in a video attached to a pull request.

Index

Constants

This section is empty.

Variables

View Source
var FFmpegPath = func() (string, error) {
	if p := os.Getenv("TB_FFMPEG"); p != "" {
		return p, nil
	}
	return exec.LookPath("ffmpeg")
}

FFmpegPath finds ffmpeg: TB_FFMPEG, else the PATH. A variable so tests need no ffmpeg.

Functions

func Burn

func Burn(ctx context.Context, path string, caps []Caption, touches []Touch) error

Burn draws caps and touches onto the video at path, in place. The captions are also written beside it (the video's name with .srt). On an error the video is left as it was.

func Changes

func Changes(ctx context.Context, path string) ([]time.Duration, error)

Changes lists when the picture in the video at path changes noticeably, in times from its start.

func FindMark added in v0.6.2

func FindMark(changes []time.Duration, held time.Duration) (time.Duration, bool)

FindMark finds the start mark among the status bar's changes: the first change followed by another about held later (the mark showing, then cleared). It returns when the mark showed, in the video's time. A video that begins on the mark shows only its clearing, about held in, with no change before: the mark showed at 0.

func Graph

func Graph(w, h, band int, caps []Caption, touches []Touch) string

Graph is the ffmpeg filter graph for a w×h video: the video at a steady outFPS, a ring (input 1, when there are touches) over each touch, then, when there are captions, a band band pixels high added below with each caption's image (the inputs after the ring, in order) in it while its step runs. Its output is [v].

func MarkChanges added in v0.6.2

func MarkChanges(ctx context.Context, path string) ([]time.Duration, error)

MarkChanges lists when the status bar's clock (the top left of the picture) changes in the first markSearch of the video at path.

func SRT

func SRT(caps []Caption) string

SRT writes caps as SubRip subtitles.

Types

type Caption

type Caption struct {
	Start, End time.Duration
	Text       string
}

Caption is a step's text, shown from Start to End (times from the video's start).

type Sync

type Sync struct {
	Shift   time.Duration // add to the runner's times to get the video's
	Matched int           // touches followed by a change within reactWithin at Shift
	Touches int
	OK      bool // enough touches agree to trust Shift
}

Sync is what Offset found.

func Offset

func Offset(touches, changes []time.Duration) Sync

Offset finds the shift that puts the touches (times by the runner's clock, from the video's start) each shortly before a change of the picture: the one that leaves the least time between each touch and the next change. That puts the quickest reaction's touch right on its change, so the shift found is the video's lag plus at most the app's quickest reaction (tens of milliseconds, under a frame or two). Between equal fits it takes the smallest shift. OK when at least two touches, and most of them, are matched.

type Touch

type Touch struct {
	At   time.Duration
	Kind string
	Pts  [][2]float64
}

Touch is a gesture: when it began (from the video's start), its kind (tap, doubleTap, longPress, swipe) and its points as fractions of the screen's width and height.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL