fix: derive poster key from plan
This commit is contained in:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user