fix: derive poster key from plan

This commit is contained in:
William Valentin
2026-02-01 14:16:30 -08:00
parent d6e6f275b7
commit 0bf2f2d827
3 changed files with 21 additions and 3 deletions
+7 -2
View File
@@ -7,7 +7,11 @@ import { Readable } from "stream";
import sharp from "sharp";
import { computeImageVariantPlan, computeVideoPosterPlan } from "./variants";
import {
computeImageVariantPlan,
computeVideoPosterPlan,
pickSmallestVariantSize,
} from "./variants";
import {
CopyObjectCommand,
@@ -499,6 +503,7 @@ export async function handleProcessAsset(raw: unknown) {
rawTags = { ...rawTags, ffprobe: ffprobeData };
const posterPlan = computeVideoPosterPlan();
const posterSmallest = pickSmallestVariantSize(posterPlan);
const posterKeys: Record<number, string> = {};
for (const item of posterPlan) {
const size = item.size;
@@ -533,7 +538,7 @@ export async function handleProcessAsset(raw: unknown) {
});
posterKeys[size] = posterKey;
}
updates.poster_key = posterKeys[256] ?? null;
updates.poster_key = posterSmallest ? posterKeys[posterSmallest] ?? null : null;
}
if (asset.media_type === "video" && typeof updates.poster_key !== "string") {