mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-06 05:33:38 -10:00
Box image: CTA read from a frame's texts together
This commit is contained in:
1 parent
3a6e207f81
commit
3b75c22100
1 file changed
+22
-6
@@ -60,6 +60,21 @@ export function shown(m: Manifest | null): [string, number][] {
|
||||
return out
|
||||
}
|
||||
|
||||
/** what each frame from `from` (s) on shows, its texts read together in the order drawn: an end card draws its CTA as
|
||||
* lines (12-04, Elfster run 4: "Make your Wishlist and organize your Gift Exchange on Elfster." over "It's free.", each
|
||||
* alone under the CTA's share, and a cut ending on its CTA was failed for none) */
|
||||
export function shownTogether(m: Manifest | null, from: number): string[] {
|
||||
if (!m) return []
|
||||
const fps = m.fps && m.fps > 0 ? m.fps : 30
|
||||
const out = new Set<string>()
|
||||
for (const fr of m.frames ?? []) {
|
||||
if (fr.frame / fps < from) continue
|
||||
const s = (fr.text ?? []).filter((t) => (t.opacity ?? 1) > 0.05).map((t) => norm(t.text ?? "")).filter(Boolean).join(" ")
|
||||
if (s) out.add(s)
|
||||
}
|
||||
return [...out]
|
||||
}
|
||||
|
||||
const cutJob = (j: Job) => (j.contract?.kind === "cut" ? (j.contract.cut ?? null) : null)
|
||||
const cutFile = (f: FileFacts) => {
|
||||
const c = f.contract?.kind === "cut" ? f.contract.cut : undefined
|
||||
@@ -117,8 +132,9 @@ export const shapePack = check<FileFacts>({ id: "shape", text: "each cut in its
|
||||
export const sayPack = check<FileFacts>({ id: "say", text: "every phrase the brief says each cut says, heard or shown", over: "file", at: ["render", "publish", "done"], needs: "words" }, async (f) => {
|
||||
const at = cutFile(f)
|
||||
if (!at?.c.say?.length) return
|
||||
const { spoken, screen } = await heardOf(f)
|
||||
const on = (p: string) => saidAt(spoken, p, SAY_GAP) !== null || screen.some(([s]) => onScreen(s, p, SAY_GAP))
|
||||
const { spoken } = await heardOf(f)
|
||||
const together = shownTogether(f.manifest, 0)
|
||||
const on = (p: string) => saidAt(spoken, p, SAY_GAP) !== null || together.some((s) => onScreen(s, p, SAY_GAP))
|
||||
const missing = at.c.say.filter((p) => p.every !== false && !on(norm(p.text)))
|
||||
if (missing.length) found({ says: `never says or shows: ${missing.map((m) => `"${m.text}"`).join(", ")}` })
|
||||
})
|
||||
@@ -143,7 +159,7 @@ export const ctaPack = check<FileFacts>({ id: "cta", text: "each cut ends on the
|
||||
const at = cutFile(f)
|
||||
const cta = at?.c.cta
|
||||
if (!cta) return
|
||||
const { times, screen } = await heardOf(f)
|
||||
const { times } = await heardOf(f)
|
||||
const within = cta.within ?? CTA_WITHIN
|
||||
const end = f.seconds ?? times[times.length - 1]?.end ?? 0
|
||||
const last = times.filter((w) => w.end >= end - within).map((w) => norm(w.text))
|
||||
@@ -155,7 +171,7 @@ export const ctaPack = check<FileFacts>({ id: "cta", text: "each cut ends on the
|
||||
const heard = lines.map((l) => share(l, last))
|
||||
const best = Math.max(0, ...heard)
|
||||
const line = best > 0 ? lines[heard.indexOf(best)] : cta.text
|
||||
const shownLate = screen.some(([s, t]) => t >= end - within && lines.some((l) => share(l, s.split(" ")) >= CTA_SHARE))
|
||||
const shownLate = shownTogether(f.manifest, end - within).some((s) => lines.some((l) => share(l, s.split(" ")) >= CTA_SHARE))
|
||||
if (best < CTA_SHARE && !shownLate) found({ says: `no CTA in its last ${within.toFixed(0)} s (${(best * 100).toFixed(0)}% of the nearest one's words heard there): "${line}"`, seconds: [Math.max(0, end - within), end] })
|
||||
})
|
||||
|
||||
@@ -165,10 +181,10 @@ export const sayOncePack = check<Job>({ id: "say-once", text: "each phrase one c
|
||||
const once = (c?.say ?? []).filter((p) => p.every === false)
|
||||
if (!c || !once.length) return
|
||||
const cuts = j.files.filter((f) => cutOf(c, f.path))
|
||||
const heard = await Promise.all(cuts.map(heardOf))
|
||||
const heard = await Promise.all(cuts.map(async (f) => ({ ...(await heardOf(f)), together: shownTogether(f.manifest, 0) })))
|
||||
for (const p of once) {
|
||||
const n = norm(p.text)
|
||||
const by = heard.some(({ spoken, screen }) => saidAt(spoken, n, SAY_GAP) !== null || screen.some(([s]) => onScreen(s, n, SAY_GAP)))
|
||||
const by = heard.some(({ spoken, together }) => saidAt(spoken, n, SAY_GAP) !== null || together.some((s) => onScreen(s, n, SAY_GAP)))
|
||||
if (!by) found({ says: `no cut says or shows "${p.text}" (brief: "${p.from}")` })
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user