mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-06 08:46:06 -10:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b83fd4a5ec | ||
|
|
ace6115ef7 | ||
|
|
da233067b7 | ||
|
|
ee21e9ea77 |
No files matched your search
@@ -103,15 +103,33 @@ def fetch(work, cache, log=print, download=get, check=probe):
|
||||
if os.path.lexists(dest):
|
||||
os.remove(dest)
|
||||
# a link into the cache, not a copy: a project's footage is gigabytes, the same across every job (11-25); every
|
||||
# container of the job mounts the volume at the same place, so the link resolves on the GPUs too
|
||||
# container of the job mounts the volume at the same place, so the link resolves on the GPUs too. It ends at a
|
||||
# file with the take's own name (cache/named/OID/NAME, a hard link to the blob): a bundler follows the link, and
|
||||
# a composition that knows its takes by name (Framed's faces) found only a hash and framed every shot centred
|
||||
try:
|
||||
os.symlink(blob, dest)
|
||||
os.symlink(named(cache, oid, path), dest)
|
||||
except OSError:
|
||||
shutil.copyfile(blob, dest)
|
||||
log(f"raea farm: {len(objects)} media files by hash, {fetched / 1e6:.1f} MB from R2, {cached / 1e6:.1f} MB already here")
|
||||
return {"objects": len(objects), "fetched": fetched, "cached": cached}
|
||||
|
||||
|
||||
def named(cache, oid, path):
|
||||
"""the blob under the take's own name, cache/named/OID/NAME: a hard link (the same file, no space), else the blob"""
|
||||
blob = os.path.join(cache, oid)
|
||||
out = os.path.join(cache, "named", oid, os.path.basename(path))
|
||||
if os.path.exists(out) and os.path.getsize(out) == os.path.getsize(blob):
|
||||
return out
|
||||
try:
|
||||
os.makedirs(os.path.dirname(out), exist_ok=True)
|
||||
tmp = f"{out}.part-{os.getpid()}"
|
||||
os.link(blob, tmp)
|
||||
os.replace(tmp, out)
|
||||
return out
|
||||
except OSError:
|
||||
return blob
|
||||
|
||||
|
||||
def is_media(path, size):
|
||||
ext = path.rsplit(".", 1)[-1].lower() if "." in os.path.basename(path) else ""
|
||||
return ext in MEDIA or size >= LARGE
|
||||
|
||||
@@ -285,7 +285,8 @@ export function localSources(manifest: { sounds?: { clips?: { src: string }[] }
|
||||
const byOid = new Map(media.map((m) => [m.oid, m.path]))
|
||||
let n = 0
|
||||
for (const c of manifest.sounds?.clips ?? []) {
|
||||
const oid = /(?:^|\/)(?:blobs\/)?([0-9a-f]{64})$/.exec(c.src)?.[1]
|
||||
// the farm's blob (blobs/OID) or the same under its own name (blobs/named/OID/NAME)
|
||||
const oid = /(?:^|\/)(?:blobs\/)?(?:named\/)?([0-9a-f]{64})(?:\/[^/]+)?$/.exec(c.src)?.[1]
|
||||
const p = oid ? byOid.get(oid) : undefined
|
||||
if (p) {
|
||||
c.src = path.join(root, p)
|
||||
|
||||
@@ -211,10 +211,14 @@ async function main() {
|
||||
}
|
||||
}
|
||||
say(`raea goal check ${path.basename(made)} --at render`)
|
||||
const r = spawnSync(REAL, ["make", "check", made, "--at", "render"], { stdio: "inherit", env: { ...process.env, RAEA_REAL: REAL } })
|
||||
const r = spawnSync(REAL, CHECK_ARGS(made), { stdio: "inherit", env: { ...process.env, RAEA_REAL: REAL } })
|
||||
if (r.status === 1) {
|
||||
say(`${path.basename(made)} fails its checks: fix every ERROR above (each says what to change), then render again before any review`)
|
||||
process.exitCode = 1
|
||||
} else if (r.status !== 0) {
|
||||
// a refused or crashed check is loud: called by an old name, it was refused with exit 2 and every cloud render went unchecked
|
||||
say(`raea goal check couldn't check ${path.basename(made)} (exit ${r.status ?? r.signal}): the render isn't done until it can`)
|
||||
process.exitCode = r.status || 1
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -222,6 +226,9 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
/** raea's one check on a finished render, as the box runs it */
|
||||
export const CHECK_ARGS = (made: string) => ["goal", "check", made, "--at", "render"]
|
||||
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
||||
main().catch((e) => {
|
||||
say((e as Error).message)
|
||||
|
||||
@@ -79,13 +79,17 @@ ws = job([{"path": "media/int1.MOV", "oid": soid, "size": len(sent)}])
|
||||
gets = hits["GET"]
|
||||
ss = fm.fetch(ws, cache, log=lambda _: None)
|
||||
assert open(os.path.join(ws, "media/int1.MOV"), "rb").read() == sent and os.path.islink(os.path.join(ws, "media/int1.MOV"))
|
||||
# followed to the end, the link is a file with the take's own name: a bundler resolves it, and a composition that knows
|
||||
# its takes by name (Framed's faces) still finds this one
|
||||
real = os.path.realpath(os.path.join(ws, "media/int1.MOV"))
|
||||
assert os.path.basename(real) == "int1.MOV" and os.path.samefile(real, os.path.join(cache, soid)), real
|
||||
assert ss == {"objects": 1, "fetched": 0, "cached": len(sent)} and hits["GET"] == gets, ss
|
||||
try:
|
||||
fm.fetch(job([{"path": "media/gone.MOV", "oid": "ab" * 32, "size": 10}]), cache, log=lambda _: None)
|
||||
raise AssertionError("footage never sent was used")
|
||||
except ValueError as e:
|
||||
assert "never sent" in str(e)
|
||||
ok("footage the box sent the farm itself comes from the cache as a link, and footage it never sent is refused")
|
||||
ok("footage the box sent the farm itself comes from the cache as a link that ends at its own name, and footage it never sent is refused")
|
||||
|
||||
w1 = job([obj])
|
||||
s1 = fm.fetch(w1, cache, log=lambda _: None)
|
||||
|
||||
@@ -213,6 +213,10 @@ console.log("units: ok")
|
||||
assert.equal(localSources(m, [{ path: "media/raw/a1_hl1.mov", oid }], "/work/project"), 1)
|
||||
assert.deepEqual(m.sounds.clips.map((c) => c.src), ["/work/project/media/raw/a1_hl1.mov", "/work/abc/media/music.mp3", "f".repeat(64)])
|
||||
assert.equal(localSources({}, [], "/x"), 0)
|
||||
// the farm's blob under the take's own name (blobs/named/OID/NAME) maps back the same
|
||||
const named = { sounds: { clips: [{ src: `/__modal/volumes/vo-F8fh/blobs/named/${oid}/a1_hl1.mov` }] } }
|
||||
assert.equal(localSources(named, [{ path: "media/raw/a1_hl1.mov", oid }], "/work/project"), 1)
|
||||
assert.equal(named.sounds.clips[0].src, "/work/project/media/raw/a1_hl1.mov")
|
||||
console.log("ok localSources")
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +121,27 @@ export function seams(words: Word[]): { at: number; before: string; after: strin
|
||||
return out
|
||||
}
|
||||
|
||||
/** a manifest's clips with every seam that isn't an edit joined: a take that plays straight on across two clips (the
|
||||
* same source and level, touching in the cut and in the take, no fade between) is one clip, so its seam is never read
|
||||
* as an edit point. A composition splits a clip that way when it reframes or restyles a shot mid-clip */
|
||||
export function joined(clips: Clip[], fps: number): Clip[] {
|
||||
const out: Clip[] = []
|
||||
const frame = 1.5 / fps
|
||||
for (const c of [...clips].sort((p, q) => p.from - q.from)) {
|
||||
const prev = out.findLast((p) => p.src === c.src && Math.abs(p.to - c.from) <= 1)
|
||||
const on =
|
||||
prev &&
|
||||
(prev.gainDb ?? 0) === (c.gainDb ?? 0) &&
|
||||
prev.bus === c.bus &&
|
||||
!prev.fadeOut &&
|
||||
!c.fadeIn &&
|
||||
Math.abs(prev.at + (prev.to - prev.from) / fps - c.at) <= frame
|
||||
if (prev && on) Object.assign(prev, { to: c.to, fadeOut: c.fadeOut })
|
||||
else out.push({ ...c })
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** a voice clip's in and out: inside a word, or on sound */
|
||||
export function editPoints(c: Clip, fps: number, words: Word[], l: Levels): Finding[] {
|
||||
const out: Finding[] = []
|
||||
@@ -210,7 +231,7 @@ export async function soundOf(f: FileFacts): Promise<{ findings: Finding[]; voic
|
||||
out.push({ level: "error", kind: "manifest", at: null, says: `its render manifest holds ${frames} of the cut's ${length} frames, so its edit can't be checked: render the cut again` })
|
||||
const heard: Heard[] = []
|
||||
let voice = 0
|
||||
for (const c of m.sounds?.clips ?? []) {
|
||||
for (const c of joined(m.sounds?.clips ?? [], fps)) {
|
||||
const kind = busOf(c)
|
||||
const file = f.take(c.src)
|
||||
if (!file) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { test } from "bun:test"
|
||||
import assert from "node:assert/strict"
|
||||
import type { Clip } from "../src/facts.ts"
|
||||
import type { Levels } from "../src/media.ts"
|
||||
import { balance, busOf, editPoints, nearestGap, soundOf, type Heard } from "../src/packs/sound.ts"
|
||||
import { balance, busOf, editPoints, joined, nearestGap, soundOf, type Heard } from "../src/packs/sound.ts"
|
||||
|
||||
test("the sound pack's measures", async () => {
|
||||
// the sound pack's measures, on made-up takes
|
||||
@@ -114,3 +114,15 @@ test("a word timed longer than a word runs is no word to cut in two (12-04, Elfs
|
||||
// a cut 4 s into the stretch, on quiet: nothing to say about a word
|
||||
assert.equal(editPoints(clip, 30, words, take).filter((f) => f.kind === "edit-in-word").length, 0)
|
||||
})
|
||||
|
||||
test("a take that plays straight on across two clips is one clip: its seam is no edit point", () => {
|
||||
const take = "/w/footage/Acme_Interview.mp4"
|
||||
const a: Clip = { from: 76, to: 96, src: take, at: 53.7, gainDb: 5.5 }
|
||||
const b: Clip = { from: 96, to: 183, src: take, at: 54.3667, gainDb: 5.5 }
|
||||
assert.deepEqual(joined([b, a], 30), [{ ...a, to: 183, fadeOut: undefined }])
|
||||
// a real cut: the take jumps, or the level changes, or the two meet in a fade
|
||||
assert.equal(joined([a, { ...b, at: 92.9 }], 30).length, 2)
|
||||
assert.equal(joined([a, { ...b, gainDb: -1 }], 30).length, 2)
|
||||
assert.equal(joined([{ ...a, fadeOut: 0.2 }, b], 30).length, 2)
|
||||
assert.equal(joined([a, { ...b, src: "/w/footage/Other.mp4" }], 30).length, 2)
|
||||
})
|
||||
@@ -114,7 +114,8 @@ function CaptionLine({ g, saying, px, accent, style, className, children }: { g:
|
||||
fontSize: px,
|
||||
lineHeight: 1.05,
|
||||
color: "var(--brand-text, #fff)",
|
||||
textShadow: "0 4px 24px rgba(0,0,0,0.55)",
|
||||
// a crisp dark edge under the soft shadow: the words hold 3:1 over a white product shot or sky, not only over faces
|
||||
textShadow: "0 0 2px rgba(0,0,0,0.95), 0 0 6px rgba(0,0,0,0.8), 0 4px 24px rgba(0,0,0,0.55)",
|
||||
overflowWrap: "break-word",
|
||||
...style,
|
||||
}}
|
||||
|
||||
@@ -42,7 +42,9 @@ pub fn stats(rgba: &[u8]) -> Option<Exposure> {
|
||||
let enc = if y <= 0.0031308 { 12.92 * y } else { 1.055 * y.powf(1.0 / 2.4) - 0.055 };
|
||||
sum_luma += enc;
|
||||
hist[(enc * 255.0).round().clamp(0.0, 255.0) as usize] += 1;
|
||||
if p[0].max(p[1]).max(p[2]) >= 254 {
|
||||
// white is every channel at the top: a saturated colour (a flat yellow sun, pale sand) has one channel there and
|
||||
// isn't clipped
|
||||
if p[0].min(p[1]).min(p[2]) >= 254 {
|
||||
hi += 1;
|
||||
}
|
||||
if p[0].max(p[1]).max(p[2]) <= 1 {
|
||||
@@ -170,6 +172,15 @@ mod tests {
|
||||
assert!(b.found("f").iter().any(|(_, s)| s.contains("crush to black")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_saturated_colour_is_not_clipped_white() {
|
||||
let sun: Vec<u8> = (0..100).flat_map(|_| [255, 184, 0, 255]).collect();
|
||||
let sand: Vec<u8> = (0..100).flat_map(|_| [255, 229, 165, 255]).collect();
|
||||
assert_eq!(stats(&sun).unwrap().clipped_high, 0.0);
|
||||
assert_eq!(stats(&sand).unwrap().clipped_high, 0.0);
|
||||
assert!(stats(&sun).unwrap().found("f").iter().all(|(_, s)| !s.contains("clip to white")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn percentiles_and_transparency() {
|
||||
// half black, half white: p01 black, p99 white; transparent pixels ignored
|
||||
|
||||
@@ -25,6 +25,7 @@ NAMES=(
|
||||
'raea-runtime-(cut|goal)-plan => sdk/goal (raea/goal)'
|
||||
'naming-check\.ts => raea/goal'"'"'s naming pack'
|
||||
'raea make (check|seen|look|judge|gates)\b => raea goal check|seen|judge|gates (MK45: goal is the loop, make the asset tools)'
|
||||
'"make", *"(check|seen|look|judge|gates)" => ["goal", "check", ...]: a spawned raea make check is refused with exit 2'
|
||||
'raea make plan\b => raea make blockout (a project'"'"'s tasks: raea goal tasks)'
|
||||
'raea next\b => raea goal next'
|
||||
'raea (clothes|motion|solid|wear|splat|physics|bake|sao|tokensynth|sounds|component)( |`|$) => raea make clothes, motion, solid... (MK45: the asset tools are under make)'
|
||||
|
||||
Reference in new issue
Block a user