feat: prefer derived mp4 playback with fallback

This commit is contained in:
William Valentin
2026-02-01 15:58:11 -08:00
parent 4fecfd469f
commit 5058afc980
3 changed files with 75 additions and 5 deletions

View File

@@ -0,0 +1,22 @@
type Variant = {
kind: "video_mp4";
size: number;
key: string;
};
type PlaybackInput = {
originalMimeType: string | null | undefined;
variants: Variant[];
};
export function pickVideoPlaybackVariant(input: PlaybackInput):
| { kind: "video_mp4"; size: number }
| { kind: "original" } {
const mp4Variant = input.variants.find(
(variant) => variant.kind === "video_mp4" && variant.size === 720,
);
if (mp4Variant) {
return { kind: "video_mp4", size: mp4Variant.size };
}
return { kind: "original" };
}