Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
import type { FetchStats, FileSpec } from "./materialize";
import type { Run } from "./mp4";
export const COMPRESSION_BPP = {
Maximum: 0.3,
Social: 0.15,
Web: 0.08,
Potato: 0.04,
} as const;
export type Compression = keyof typeof COMPRESSION_BPP;
export const MIN_PART = 5 * 1024 * 1024;
export type VideoTask = {
kind: "video";
taskId: string;
/** Dispatch attempt; echoed in failures so stale ones are ignored. */
attempt?: number;
jobId: string;
chunk: number;
fps: number;
resolution: [number, number];
bpp: number;
frames: [number, number];
/** x264 threads, fixed per job: output bytes must not depend on the machine. */
threads: number;
files: FileSpec[];
upload: {
key: string;
uploadId: string;
firstPart: number;
partLimit: number;
partTarget: number;
/** In the farm's own bucket, not the media bucket (see stitch.ts). */
stashKey: string;
};
audio: { first: number; end: number; coordinator: string } | null;
/** Stream playable fMP4 segments to `${prefix}/c<chunk>-<n>.m4s` while rendering. */
hls: { prefix: string; segmentFrames: number } | null;
};
export type SegmentReport = {
chunk: number;
index: number;
/** Global output frames [first, end). */
frames: [number, number];
key: string;
/** The chunk's final segment. */
last: boolean;
/** Base64 Annex B SPS/PPS, for the init segment. */
extradata: string;
};
export type AudioTask = {
kind: "audio";
taskId: string;
attempt?: number;
jobId: string;
section: number;
fps: number;
range: [number, number];
preroll: number;
files: FileSpec[];
};
export type Task = VideoTask | AudioTask;
/**
* Re-encodes a source the planner cannot index (a browser recording's WebM
* has no seek index and rare keyframes) into an H.264 MP4 with a keyframe
* every `keyframeSeconds`, so chunks can start anywhere in it.
*/
export type TranscodeTask = {
kind: "transcode";
taskId: string;
attempt?: number;
source: string;
output: string;
keyframeSeconds: number;
};
export type WorkItem = Task | TranscodeTask;
export type TaskTimings = {
queuedMs: number;
fetch: FetchStats;
engine: Record<string, number>;
engineMs: number;
audioWaitMs: number;
uploadMs: number;
totalMs: number;
cpuSeconds: number;
};
export type VideoResult = {
taskId: string;
worker: string;
sizes: number[];
keyframes: number[];
extradata: string;
width: number;
height: number;
/** Runs relative to the chunk's first byte; `first` is a global sample index. */
videoRuns: Run[];
audioRuns: Run[];
/** Names the dispatch's HLS segments even when the chunk uploaded no parts. */
firstPart: number;
stash: { key: string; bytes: number };
parts: { partNumber: number; etag: string; size: number }[];
bytes: number;
timings: TaskTimings;
};
export type AudioResultMeta = {
taskId: string;
worker: string;
firstPacket: number;
sizes: number[];
extradata: string;
timings: TaskTimings;
};
export type JobRequest = {
recording: string;
fps?: number;
resolution?: [number, number];
compression?: Compression;
/** Upper bound on video chunks; defaults to one per registered slot. */
maxChunks?: number;
minChunkSeconds?: number;
chunksPerSlot?: number;
/** Target render seconds per chunk. */
chunkWorkSeconds?: number;
duplicateStragglers?: boolean;
label?: string;
/** Profiling: export only the first N frames, without audio. */
frameLimit?: number;
/** Pin the chunk count (profiling). */
chunks?: number;
/**
* Folder the recording belongs to (e.g. a video's root). Manifest keys and
* outputs may point anywhere inside it, not only inside `recording`.
*/
sourceRoot?: string;
/** Where the MP4 and HLS segments go; default `out/<id>.mp4` and `hls/<id>`. */
output?: { key: string; hlsPrefix?: string };
/** Receives the job summary (HMAC-signed) once the export is ready or failed. */
callbackUrl?: string;
/** Opaque, echoed in callbacks. */
reference?: string;
};