Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

3.3 KB
Raw Blame
/**
 * Where the demo loops live and which file a reader gets.
 *
 * The loops are served from Cloudflare R2, not from website/static/. Everything
 * under static/ is committed to git for good (scripts/check-media-budget.mjs
 * says why), and eighteen 1080p60 clips in two codecs and two sizes are about
 * 75 MB per cut. The bucket holds them outside the repository; the folder name
 * is the cut, so a re-encode goes to a new folder and the old files can keep
 * their year-long cache. media/loops.json records every published file by size
 * and hash, and the block below is written by the same publish script.
 */

// @generated by scripts/media/publish-loops.mjs: start
export const LOOP_BASE = "https://media.getopenscreen.com/loops/2026-10b";

/** Seconds, from the 1080p H.264 file of each loop. */
export const LOOP_DURATIONS: Record<string, number> = {
	"3d-camera": 5.4,
	"3d-cursors": 6.97,
	"animated-backgrounds": 7.5,
	"ask-the-agent": 7.6,
	"automatic-subtitles": 4.8,
	"background-picker": 11.2,
	"beautiful-by-default": 11,
	"camera-blur": 6.6,
	"caption-styles": 6.2,
	"classic-zoom": 5.2,
	"device-frames": 4.85,
	"edit-by-transcript": 4.5,
	"edit-like-a-doc": 4.8,
	"every-format": 5.4,
	"every-layout": 8.2,
	"sensitive-data-mask": 8.7,
	"simpler-editor": 4.4,
	"tighten-pauses": 7.4,
};

/** When this cut was published: the VideoObject uploadDate. */
export const LOOP_PUBLISHED = "2026-10-02";
// @generated by scripts/media/publish-loops.mjs: end

export const LOOP_NAMES = [
	"classic-zoom",
	"3d-camera",
	"3d-cursors",
	"automatic-subtitles",
	"caption-styles",
	"edit-by-transcript",
	"tighten-pauses",
	"background-picker",
	"every-format",
	"sensitive-data-mask",
	"camera-blur",
	"every-layout",
	"device-frames",
	"animated-backgrounds",
	"beautiful-by-default",
	"simpler-editor",
	"edit-like-a-doc",
	"ask-the-agent",
] as const;

export type LoopName = (typeof LOOP_NAMES)[number];

export type LoopHeight = 720 | 1080;

/**
 * The smaller file whenever it is sharp enough. Every loop is 16:9, so the
 * height a box needs is its width × 9/16 in device pixels. The ratio is capped
 * at 2: a 3× phone shows a column a few hundred CSS pixels wide, where 720 rows
 * are already more than it can resolve.
 */
export function pickHeight(cssWidth: number, devicePixelRatio: number): LoopHeight {
	const dpr = Math.min(Math.max(devicePixelRatio || 1, 1), 2);
	const rows = (cssWidth * dpr * 9) / 16;
	return rows > 760 ? 1080 : 720;
}

/**
 * The codec strings are the encoder's real profile and level (ffprobe on the
 * files), not the bare "hvc1": an engine that can decode HEVC Main only up to a
 * lower level should say no here and take the H.264 file, rather than say yes
 * and stall. HEVC is listed first because it is the better file, measured with
 * VMAF against the masters: 23% lighter at equal quality on every-layout, and
 * 97.8 against 96.0 at equal size on 3d-cursors.
 */
export function loopSources(name: LoopName, height: LoopHeight) {
	return [
		{
			src: `${LOOP_BASE}/${name}-${height}-hevc.mp4`,
			type: `video/mp4; codecs="hvc1.1.6.L${height === 1080 ? 123 : 120}.B0"`,
		},
		{
			src: `${LOOP_BASE}/${name}-${height}-h264.mp4`,
			type: `video/mp4; codecs="avc1.64002a"`,
		},
	];
}

export function loopPoster(name: LoopName): string {
	return `${LOOP_BASE}/${name}-poster.webp`;
}