import { ProxyVariant } from './mediaCodecMap.js'; /** * Transcodes browser-hostile local video sources (HEVC, ProRes, ...) into a * cached, seekable authoring proxy. Consumed by the preview/play/static * project routes (U3/U4) to serve a `?hf-proxy=` request; never used on * the render path (render always sees the original file). * * IMPORTANT — request-lifecycle detachment: nothing here accepts or wires an * AbortSignal. `resolveProxy` returns a promise shared by every concurrent * caller for the same cache key (in-flight dedupe below); if a route handler * killed the ffmpeg child on client abort (page reload, HMR), every other * caller waiting on that same promise would fail too, and the next request * would restart a transcode that may have been minutes into a long asset. * Callers MUST let the child run to completion regardless of request * cancellation and simply let the held response also abort — the cache * entry still lands for the next request. */ declare const PROXY_PARAMS_VERSION = "v4"; declare const TRANSCODE_TIMEOUT_MS: number; declare const DEFAULT_PROXY_WAIT_TIMEOUT_MS: number; declare class ProxyTranscodeError extends Error { readonly exitCode: number | null; readonly stderrTail: string; constructor(message: string, exitCode: number | null, stderrTail: string); } declare class FfmpegMissingFilterError extends ProxyTranscodeError { constructor(); } declare class ProxyCapacityError extends ProxyTranscodeError { constructor(); } declare class ProxySourceOutsideProjectError extends ProxyTranscodeError { constructor(); } declare class ProxyWaitTimeoutError extends ProxyTranscodeError { constructor(timeoutMs: number); } /** Bounds one caller's wait without cancelling the shared in-flight ffmpeg * job. Other preview/publish callers still receive the completed cache entry. */ declare function waitForProxy(promise: Promise, timeoutMs?: number): Promise; /** * Computes the absolute path a proxy for this source would live at, without * transcoding anything. Route handlers use this to check cache state (e.g. * for ETag/If-None-Match) before deciding whether to await a transcode. */ declare function getProxyCachePath(projectDir: string, absoluteSourcePath: string, variant?: ProxyVariant): string; /** Test hook: forget remembered transcode failures (module state persists * across tests that don't reload the module). */ declare function clearFailedTranscodesForTest(): void; /** * Resolves the cached proxy variant for `absoluteSourcePath`, transcoding it at * most once per cache key. Concurrent calls for the same key (including a * pre-warm call racing an element-triggered one) share one ffmpeg child and * one promise; calls for different keys queue through the global concurrency * limiter above. Throws `ProxyTranscodeError` on failure (missing ffmpeg or a * nonzero exit) — callers (route handlers) decide how to surface that (502). */ declare function resolveProxy(projectDir: string, absoluteSourcePath: string, variant?: ProxyVariant): Promise; export { DEFAULT_PROXY_WAIT_TIMEOUT_MS, FfmpegMissingFilterError, PROXY_PARAMS_VERSION, ProxyCapacityError, ProxySourceOutsideProjectError, ProxyTranscodeError, ProxyWaitTimeoutError, TRANSCODE_TIMEOUT_MS, clearFailedTranscodesForTest, getProxyCachePath, resolveProxy, waitForProxy };