/** * Lazy index of a video track's keyframe timestamps, in seconds. * * Seeking decodes forward from the keyframe at-or-before the target, so every * seek needs that anchor. Resolving one costs a container round-trip, so the * index remembers each keyframe it discovers; repeated seeks around the same * region then resolve synchronously through `cachedAtOrBefore`. */ /** * Opaque packet handle. Only `timestamp` is read; the object is threaded back * into `getNextKeyPacket` unchanged so the probe's hidden packet fields survive. */ export interface KeyframePacketLike { readonly timestamp: number; } interface KeyframeRetrievalOptions { readonly metadataOnly?: boolean; } /** The slice of mediabunny's `EncodedPacketSink` the index depends on. */ export interface KeyframeProbe { getKeyPacket(timestamp: number, options?: KeyframeRetrievalOptions): Promise; getNextKeyPacket(packet: KeyframePacketLike, options?: KeyframeRetrievalOptions): Promise; } /** * Distribution of the gaps between discovered keyframes, in seconds. A long * maxGopS (or a high stddev) is the badly-encoded-source tell: an off-anchor * seek must decode forward from the prior keyframe, so a long GOP is a wall of * frames every scrub pays for. Zeros when fewer than two keyframes are known. */ export interface GopStats { readonly count: number; readonly avgGopS: number; readonly maxGopS: number; readonly minGopS: number; readonly stddevS: number; readonly densityPerS: number; } export declare class KeyframeIndex { private readonly probe; private readonly times; private probeRoundTrips; /** Set once a full walk has completed, so a second call is a free no-op. */ private fullyIndexed; constructor(probe: KeyframeProbe); /** Keyframe timestamps discovered so far, ascending and deduplicated. */ get known(): readonly number[]; /** Container queries the index has made; the rest resolve from memory. */ get probeCount(): number; /** * GOP-gap distribution over the keyframes discovered so far. Pass the track * duration so density reflects keyframes across the whole clip, not just the * clustered swept span; without it a few discovered keyframes in one region * would read as a high density that does not hold track-wide. */ gopStats(durationS?: number): GopStats; /** * Nearest keyframe at or before `tSec`, the anchor a seek decodes forward * from. Null when `tSec` precedes the first keyframe. */ keyframeAtOrBefore(tSec: number): Promise; /** * First keyframe strictly after `tSec`, the boundary a forward decode runs * up to. Null when no keyframe follows, or when `tSec` precedes the first * keyframe (no anchor to step from). */ nextKeyframeAfter(tSec: number): Promise; /** * Every keyframe needed to decode the window `[startS, endS]`: the anchor at * or before `startS` plus each keyframe up to `endS`. Empty when `startS` * precedes the first keyframe. */ keyframesCovering(startS: number, endS: number): Promise; /** * Walks the whole track once, recording every keyframe timestamp. Metadata * only: it threads the same getKeyPacket / getNextKeyPacket pattern as the * lazy probes, so it never decodes a pixel. Idempotent: a second call after a * completed walk returns at once. Meant for the diagnostics lane, off the hot * seek path, so the purple lane reflects the whole file rather than only the * regions a scrub has visited. */ ensureFullyIndexed(fromS?: number): Promise; /** * Largest discovered keyframe at or before `tSec`, resolved synchronously * from memory. Null when nothing at or before `tSec` has been discovered * yet; callers fall back to the async probes above. */ cachedAtOrBefore(tSec: number): number | null; private record; } export {};