Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

TL4c: in progress: a film's scene is its picture and its sound together (fromRender has no separate sound clip), so a cut, a move or a speed takes both, as the player plays them from the one file; 53 tests

shinyobjectze3b048e2d9f8
diff --git a/sdk/timeline/src/read.ts b/sdk/timeline/src/read.ts
index 96bfc782..e48ee6cc 100644
--- a/sdk/timeline/src/read.ts
+++ b/sdk/timeline/src/read.ts
@@ -45,14 +45,13 @@ export function fromSequences(rows: SeqRow[], fps: number): Timeline {
return { ...empty(fps), tracks, magnet: gapless }
}
-/** A film with no composition behind it: its scenes as clips of one main track (cut where the picture cuts), and
- * its sound as one clip under them. Its magnet is on: a scene removed closes up, as a cut of footage does. */
-export function fromRender(o: { frames: Frames; fps: number; cuts?: Frames[]; sound?: boolean }): Timeline {
+/** A film with no composition behind it: its scenes as clips of one main track (cut where the picture cuts). Each
+ * clip is the film's picture and its sound together, as footage is until its sound is extracted (TL4c), so a cut,
+ * a move or a speed takes both. Its magnet is on: a scene removed closes up, as a cut of footage does. */
+export function fromRender(o: { frames: Frames; fps: number; cuts?: Frames[] }): Timeline {
const edges = [0, ...[...new Set(o.cuts ?? [])].filter((c) => c > 0 && c < o.frames).sort((a, b) => a - b), o.frames]
const scenes: Clip[] = edges.slice(0, -1).map((from, n) => ({ id: `scene-${n + 1}`, kind: "video", name: `Scene ${n + 1}`, start: from, length: edges[n + 1] - from, in: from, source: o.frames }))
- const tracks: Track[] = [{ id: "main", kind: "main", clips: scenes }]
- if (o.sound) tracks.push({ id: "sound-1", kind: "sound", clips: [{ id: "sound", kind: "audio", name: "Sound", start: 0, length: o.frames, in: 0, source: o.frames }] })
- return { ...empty(o.fps), tracks }
+ return { ...empty(o.fps), tracks: [{ id: "main", kind: "main", clips: scenes }] }
}
/** A render's cut, as the frames of the source played in order (the hand edit's `segments`): what a film's main
diff --git a/sdk/timeline/test/play.test.ts b/sdk/timeline/test/play.test.ts
index fb107f39..ae5411f5 100644
--- a/sdk/timeline/test/play.test.ts
+++ b/sdk/timeline/test/play.test.ts
@@ -7,7 +7,7 @@ const done = (t: Timeline, op: Parameters<typeof apply>[1]) => {
return r.timeline
}
// a 10 s film at 30 fps cut at 3 s and 6 s
-const film = () => fromRender({ frames: 300, fps: 30, cuts: [90, 180], sound: true })
+const film = () => fromRender({ frames: 300, fps: 30, cuts: [90, 180] })
describe("TL10a: an edited film plays from its own frames, with no render", () => {
test("unedited, each frame shows itself", () => {
diff --git a/sdk/timeline/test/read.test.ts b/sdk/timeline/test/read.test.ts
index 4a72e74a..91ce8945 100644
--- a/sdk/timeline/test/read.test.ts
+++ b/sdk/timeline/test/read.test.ts
@@ -51,9 +51,9 @@ describe("TL0c: a timeline is read from a composition", () => {
describe("TL14a: a film with no composition is its scenes and its sound", () => {
test("scenes cut where the picture cuts, and the cut they make after edits", () => {
- const t = fromRender({ frames: 300, fps: 30, cuts: [90, 210, 210, 400], sound: true })
+ const t = fromRender({ frames: 300, fps: 30, cuts: [90, 210, 210, 400] })
expect(t.tracks[0].clips.map((c) => [c.id, c.start, c.length])).toEqual([["scene-1", 0, 90], ["scene-2", 90, 120], ["scene-3", 210, 90]])
- expect(t.tracks[1].clips[0]).toMatchObject({ kind: "audio", length: 300 })
+ expect(t.tracks.length).toBe(1)
expect(segmentsOf(t)).toEqual([[0, 90], [90, 210], [210, 300]])
// the second scene removed, the third trimmed by 30 frames at its start, then moved first
let cut = done(t, { op: "remove", ids: ["scene-2"] })