Complete ffmpeg movie fallback wiring

This commit is contained in:
mes123456
2026-09-07 17:17:44 +08:00
parent 72bf0f47ad
commit 93c01c8f09
2 changed files with 28 additions and 0 deletions

View File

@@ -129,6 +129,19 @@ export async function probeSequencerCodec(
return probeMovie(request, source);
}
/** Probe a movie with the browser decoder first, then use the local ffmpeg.wasm
* Worker when Chromium cannot decode the container/codec. */
export async function probeSequencerMovieCodecWithFallback(
requestValue: unknown,
source: ArrayBuffer,
signal?: AbortSignal,
): Promise<SequencerCodecProbeResultIR> {
const browserResult = await probeSequencerCodec(requestValue, source);
if (browserResult.status === "READY") return browserResult;
const { probeMovieWithFFmpeg } = await import("./FFmpegMovieProbe");
return probeMovieWithFFmpeg(requestValue, source, signal);
}
export function createSequencerCodecProbeRequest(
stripType: SequencerCodecProbeRequestIR["stripType"],
mimeType: string,

View File

@@ -88,6 +88,21 @@ export async function generateInitialSequencerMovieProxyFrame(
throw new SequencerMediaCacheValidationError("SEQUENCER_CACHE_SOURCE_MISMATCH", "Movie proxy source bytes failed identity verification");
}
cancelled(signal);
if (capability.backend === "FFMPEG_WASM") {
try {
const { decodeMovieFrameWithFFmpeg } = await import("./FFmpegMovieProbe");
const frame = await decodeMovieFrameWithFFmpeg(source, sourceData, profile.width, profile.height, signal);
cancelled(signal);
return {
manifest: await createSequencerMediaCacheManifest(source, capability, profile, 0, frame.rgba),
data: frame.rgba,
};
}
catch (error) {
if (error instanceof DOMException && error.name === "AbortError") throw new SequencerMediaCacheValidationError("SEQUENCER_CANCELLED", "Movie proxy generation was cancelled");
throw new SequencerMediaCacheValidationError("SEQUENCER_CODEC_UNSUPPORTED", "ffmpeg.wasm movie proxy frame decode failed");
}
}
if (typeof document === "undefined" || typeof HTMLMediaElement === "undefined") {
throw new SequencerMediaCacheValidationError("SEQUENCER_CODEC_UNSUPPORTED", "HTML media proxy generation is unavailable");
}