Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Home: Live edit second biggest at every width, Genjutsu clip fades before it loops

Adarsh52518c67383d
diff --git a/public/previews/home/genjutsu-1024.avif b/public/previews/home/genjutsu-1024.avif
index 98de391c..6fce9e3b 100644
Binary files a/public/previews/home/genjutsu-1024.avif and b/public/previews/home/genjutsu-1024.avif differ
diff --git a/public/previews/home/genjutsu-1024.jpg b/public/previews/home/genjutsu-1024.jpg
index 37c32ee2..b48b0ff4 100644
Binary files a/public/previews/home/genjutsu-1024.jpg and b/public/previews/home/genjutsu-1024.jpg differ
diff --git a/public/previews/home/genjutsu-1024.mp4 b/public/previews/home/genjutsu-1024.mp4
index 4f4d3b37..58e28861 100644
Binary files a/public/previews/home/genjutsu-1024.mp4 and b/public/previews/home/genjutsu-1024.mp4 differ
diff --git a/public/previews/home/genjutsu-640.avif b/public/previews/home/genjutsu-640.avif
index bc9d2cd8..bf2e1fcd 100644
Binary files a/public/previews/home/genjutsu-640.avif and b/public/previews/home/genjutsu-640.avif differ
diff --git a/public/previews/home/genjutsu-640.mp4 b/public/previews/home/genjutsu-640.mp4
index 165bdd31..6f7c7992 100644
Binary files a/public/previews/home/genjutsu-640.mp4 and b/public/previews/home/genjutsu-640.mp4 differ
diff --git a/public/previews/home/genjutsu-768.avif b/public/previews/home/genjutsu-768.avif
new file mode 100644
index 00000000..7f8f4c90
Binary files /dev/null and b/public/previews/home/genjutsu-768.avif differ
diff --git a/public/previews/home/genjutsu-768.mp4 b/public/previews/home/genjutsu-768.mp4
new file mode 100644
index 00000000..e338491d
Binary files /dev/null and b/public/previews/home/genjutsu-768.mp4 differ
diff --git a/scripts/gen-home-bento.mjs b/scripts/gen-home-bento.mjs
index 85be8d0f..cc0f1963 100644
--- a/scripts/gen-home-bento.mjs
+++ b/scripts/gen-home-bento.mjs
@@ -13,7 +13,7 @@
* rotation-{640,1024,1536,2048}.{mp4,avif} the turning gown (the 3D tile) at four widths, and each one's first frame
* reel-sand-storm-1024.jpg, rotation-1024.jpg the 1024 px clips' first frames, for a browser without AVIF
* image-4-{480,768}.avif the Image studio's example 4
- * genjutsu-{640,1024}.{mp4,avif} Genjutsu's group swap (the Genjutsu tile) at two widths, and each one's first frame
+ * genjutsu-{640,768,1024}.{mp4,avif} Genjutsu's group swap (the Genjutsu tile) at three widths, and each one's first frame
* genjutsu-1024.jpg the 1024 px clip's first frame, for a browser without AVIF
* genjutsu-original-{240,480}.avif the original clip's first frame, for the Genjutsu tile's window
* board-{photo,film}.webp the Canvas board's photo and a frame of its film, 168 px squares
@@ -91,10 +91,15 @@ export const REEL = [
const LOOPS = [{ key: "app-3d-rotation", name: "rotation", crf: { 640: 23, 1024: 23, 1536: 27, 2048: 28 } }];
/**
* The Genjutsu tile's clip (BENTO_GENJUTSU in src/lib/home-bento.ts): `frames` frames of its render from frame `from`,
- * played on a loop as they are (a crossfade at the seam would lay one face over another), at the widths its 1024 px
- * render covers, and the CRF each is encoded at.
+ * at the widths its 1024 px render covers, and the CRF each is encoded at. It plays on a loop, and its last frame is
+ * nothing like its first, so it holds that last frame `hold` frames and fades it to the tiles' dark colour over the
+ * last `fadeOut` (a crossfade at the seam would lay one face over another); its first frame, the poster, stays as it is.
*/
-export const CUTS = [{ key: "genjutsu-group-swap", name: "genjutsu", from: 0, frames: 120, widths: [640, 1024], crf: { 640: 22, 1024: 23 } }];
+export const CUTS = [
+ { key: "genjutsu-group-swap", name: "genjutsu", from: 0, frames: 120, hold: 8, fadeOut: 8, widths: [640, 768, 1024], crf: { 640: 24, 768: 24, 1024: 23 } },
+];
+/** The colour a clip fades out to before it loops: the tiles' dark media colour (globals.css --media). */
+const FADE_COLOR = "0x0d0d0f";
/** The widths each clip and its poster are made at: a tile takes the first at least as wide as its box needs. */
const CLIP_WIDTHS = [640, 1024, 1536, 2048];
/** The widths a reel clip is made at from its render alone (wider ones need its 2048 px master). */
@@ -148,13 +153,16 @@ function loopAt(src, width) {
}
/**
- * A reel clip at `width`: `frames` frames from frame `from` of the render (at CLIP_FPS), played once, no loop. Returns
- * its y4m stream.
+ * A clip at `width`: `frames` frames from frame `from` of the render (at CLIP_FPS). A reel clip plays once, no loop;
+ * the Genjutsu clip (CUTS) then holds its last frame `hold` frames and fades out over its last `fadeOut`, ending on
+ * the fade colour. Returns its y4m stream.
*/
-function cutAt(src, width, from, frames) {
- const y4m = ffmpeg(["-v", "error", "-i", src, "-an", "-sn", "-dn", "-vf", `fps=${CLIP_FPS},trim=start_frame=${from}:end_frame=${from + frames},setpts=PTS-STARTPTS,scale=${width}:-2:flags=lanczos,format=yuv420p`, "-f", "yuv4mpegpipe", "-"]);
+function cutAt(src, width, from, frames, { hold = 0, fadeOut = 0 } = {}) {
+ const total = frames + hold;
+ const tail = (hold ? `,tpad=stop_mode=clone:stop=${hold}` : "") + (fadeOut ? `,fade=t=out:start_frame=${total - fadeOut}:nb_frames=${fadeOut - 1}:color=${FADE_COLOR}` : "");
+ const y4m = ffmpeg(["-v", "error", "-i", src, "-an", "-sn", "-dn", "-vf", `fps=${CLIP_FPS},trim=start_frame=${from}:end_frame=${from + frames},setpts=PTS-STARTPTS,scale=${width}:-2:flags=lanczos${tail},format=yuv420p`, "-f", "yuv4mpegpipe", "-"]);
const got = readY4m(y4m).frames.length;
- if (got !== frames) throw new Error(`${path.basename(src)} has ${got} frames from frame ${from}, not ${frames}`);
+ if (got !== total) throw new Error(`${path.basename(src)} has ${got} frames from frame ${from}, not ${total}`);
return y4m;
}
@@ -236,7 +244,7 @@ async function main() {
c.widths.map((w) => ({
name: `${c.name}-${w}.mp4`,
clip: true,
- make: () => encodeClipBuffer(cutAt(master(`${c.key}.mp4`), w, c.from, c.frames), c.crf[w]),
+ make: () => encodeClipBuffer(cutAt(master(`${c.key}.mp4`), w, c.from, c.frames, c), c.crf[w]),
})),
),
];
diff --git a/src/components/home/home-bento.css b/src/components/home/home-bento.css
index 2104a4af..a4d2d2c2 100644
--- a/src/components/home/home-bento.css
+++ b/src/components/home/home-bento.css
@@ -250,8 +250,9 @@
.hb-live {
aspect-ratio: 16 / 10;
}
+ /* Shorter than the live tile above it, which is the bigger one; the couple's faces still show whole. */
.hb-genjutsu {
- aspect-ratio: 3 / 2;
+ aspect-ratio: 16 / 9;
}
.hb-image,
.hb-three {
@@ -267,12 +268,13 @@
@media (min-width: 768px) {
.hb-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
- grid-template-rows: repeat(4, 210px) auto;
+ /* The reel and the live tile a little taller than the rows under them: the live tile is the bigger one. */
+ grid-template-rows: 230px 230px 210px 210px auto;
grid-template-areas:
"video video live"
"video video live"
- "genjutsu genjutsu image"
- "audio canvas three"
+ "genjutsu image three"
+ "audio canvas canvas"
"numbers numbers numbers";
}
}
@@ -485,8 +487,16 @@
font-size: 44px;
}
}
-/* From lg the live tile is the second biggest: its title a size up from the small tiles'. */
+/* From a tablet the live tile is the second biggest: its title a size up from the small tiles', and from lg two. */
+@media (min-width: 768px) {
+ .hb-live .hb-title {
+ font-size: 28px;
+ }
+}
@media (min-width: 1024px) {
+ .hb-live .hb-title {
+ font-size: 30px;
+ }
@container (min-width: 360px) {
.hb-live .hb-title {
font-size: 34px;
@@ -507,12 +517,6 @@
.hb-meta {
display: none;
}
- .hb-board {
- width: min(200px, 100% - 28px);
- }
- .hb-node-label {
- font-size: 10px;
- }
}
/* ---------------------------------------------------------------- video */
@@ -705,6 +709,14 @@
.hb-genjutsu .hb-clip video {
object-position: 50% 22%;
}
+/* From lg the tile is a short strip with its title over the lower half: the faces sit higher in it, clear of the
+ words, their heads still whole when the camera pushes in. */
+@media (min-width: 1024px) {
+ .hb-genjutsu > .hb-pic .hb-fill,
+ .hb-genjutsu .hb-clip video {
+ object-position: 50% 40%;
+ }
+}
/*
* The original clip's first frame, in a small window in the tile's top corner: what went in, beside what came out. On
* a layer over the clip and the shade, its size from the tile's own width (the tile is a container), so it never lays
@@ -745,6 +757,12 @@
right: 12px;
}
}
+/* From lg the strip is short: a smaller window keeps to its corner, clear of the man's face as the camera moves. */
+@media (min-width: 1024px) {
+ .hb-original {
+ width: clamp(64px, 22cqw, 132px);
+ }
+}
/* The reel's clips and its still: a wide, short tile crops from the bottom, so the head always shows (a clip framed
otherwise sets its own object-position: HOME_BENTO_REEL). */
.hb-video .hb-fill,
@@ -1053,6 +1071,22 @@
display: none;
}
}
+/*
+ * A short tile (from lg, the bottom row at 1024 x 768 to 1440 x 900) has about 66 px over its words: the board sits
+ * from its top, a little smaller, the steps' words whole without their icons, and the two pictures keep to themselves
+ * (the film's play mark and glow say which is which), so nothing reaches the edge or the title.
+ */
+@container (max-height: 200px) {
+ .hb-board {
+ top: 10px;
+ translate: -50% 0;
+ width: min(196px, 100% - 28px);
+ }
+ .hb-node-label,
+ .hb-step svg {
+ display: none;
+ }
+}
.hb-edges {
position: absolute;
inset: 0;
diff --git a/src/components/home/home-bento.tsx b/src/components/home/home-bento.tsx
index 405fc235..d847e26a 100644
--- a/src/components/home/home-bento.tsx
+++ b/src/components/home/home-bento.tsx
@@ -14,16 +14,16 @@ import "./home-bento.css";
* tile's width or, where the tile is the squarer shape, its height times 4/3, so the browser picks a copy that sharp.
*/
const SIZES = {
- video: "(min-width: 1024px) 572px, (min-width: 768px) 576px, calc(100vw - 32px)",
+ video: "(min-width: 1024px) 572px, (min-width: 768px) 630px, calc(100vw - 32px)",
/**
* The live tile: from lg a third of the grid wide and two rows tall (up to 570 px under cover on a 1920 x 1080
* screen), two rows tall on a tablet, the full row on a phone.
*/
- live: "(min-width: 1024px) 570px, (min-width: 768px) 580px, calc(100vw - 32px)",
+ live: "(min-width: 1024px) 570px, (min-width: 768px) 630px, calc(100vw - 32px)",
/** A 4:3 picture in a square tile on a phone (half the row): cropped at its sides, so 4/3 of the tile's width. */
square: "(min-width: 1024px) 274px, (min-width: 768px) 320px, calc((100vw - 44px) * 0.667)",
- /** The Genjutsu tile: a third of the grid wide from lg, two columns on a tablet, the full row on a phone. */
- genjutsu: "(min-width: 1024px) 376px, (min-width: 768px) 476px, calc(100vw - 32px)",
+ /** The Genjutsu tile: a third of the grid wide from lg, one column on a tablet (its 4:3 clip under cover: 280 px), the full row on a phone. */
+ genjutsu: "(min-width: 1024px) 376px, (min-width: 768px) 280px, calc(100vw - 32px)",
/** The original's window in the Genjutsu tile (home-bento.css: at most 132 px wide). */
original: "132px",
};
diff --git a/src/lib/home-bento.generated.ts b/src/lib/home-bento.generated.ts
index 25e9325f..3e103b37 100644
--- a/src/lib/home-bento.generated.ts
+++ b/src/lib/home-bento.generated.ts
@@ -12,19 +12,21 @@ export const HOME_BENTO_MEDIA: Record<string, string> = {
"/previews/home/rotation-1024.mp4": "3f5507ab",
"/previews/home/rotation-1536.mp4": "87d3d4f1",
"/previews/home/rotation-2048.mp4": "5804eda4",
- "/previews/home/genjutsu-640.mp4": "17ae2073",
- "/previews/home/genjutsu-1024.mp4": "6611d454",
+ "/previews/home/genjutsu-640.mp4": "dc3680bd",
+ "/previews/home/genjutsu-768.mp4": "003cd587",
+ "/previews/home/genjutsu-1024.mp4": "4a1c92ad",
"/previews/home/reel-sand-storm-640.avif": "6e339255",
"/previews/home/reel-sand-storm-1024.avif": "13b5d74a",
"/previews/home/rotation-640.avif": "c69b0d7b",
"/previews/home/rotation-1024.avif": "23d2a89b",
"/previews/home/rotation-1536.avif": "b3df3778",
"/previews/home/rotation-2048.avif": "bcc9ccc5",
- "/previews/home/genjutsu-640.avif": "78148871",
- "/previews/home/genjutsu-1024.avif": "61b49f42",
+ "/previews/home/genjutsu-640.avif": "5773faa7",
+ "/previews/home/genjutsu-768.avif": "be299a65",
+ "/previews/home/genjutsu-1024.avif": "c7c045c3",
"/previews/home/reel-sand-storm-1024.jpg": "cab53f24",
"/previews/home/rotation-1024.jpg": "61a2cbc9",
- "/previews/home/genjutsu-1024.jpg": "c69400ea",
+ "/previews/home/genjutsu-1024.jpg": "1b5d1a56",
"/previews/home/image-4-480.avif": "5a6d07a1",
"/previews/home/image-4-768.avif": "ef9d1b4d",
"/previews/home/genjutsu-original-240.avif": "ecc3f2d0",
@@ -57,7 +59,7 @@ export const HOME_BENTO_REEL = [
export const HOME_BENTO_TINT: Record<string, string> = {
"reel-sand-storm": "#b06c4c",
"rotation": "#bfbeb6",
- "genjutsu": "#796c56"
+ "genjutsu": "#786b54"
};
export const HOME_BENTO_WAVE = {
diff --git a/src/lib/home-bento.ts b/src/lib/home-bento.ts
index 6ec8e2d2..757dcb16 100644
--- a/src/lib/home-bento.ts
+++ b/src/lib/home-bento.ts
@@ -39,8 +39,8 @@ export const BENTO_IMAGE_EXAMPLE = { id: "image.4", out: "/examples/image/4/out.
* a small window. Its id in the playback store is its own, so a card lower down can play the same clip.
*/
export const BENTO_GENJUTSU = { id: "home-genjutsu", cover: "genjutsu-group-swap", name: "genjutsu", original: "genjutsu-original" } as const;
-/** The widths the Genjutsu clip comes in: its render is 1024 px wide, and nothing is made up past that. */
-export const BENTO_GENJUTSU_WIDTHS = [640, 1024] as const;
+/** The widths the Genjutsu clip comes in: its render is 1024 px wide, and nothing is made up past that (768 for a 2x laptop). */
+export const BENTO_GENJUTSU_WIDTHS = [640, 768, 1024] as const;
/** The widths of the original's window (it shows at up to about 130 px wide: 480 covers a 3x screen). */
export const BENTO_ORIGINAL_WIDTHS = [240, 480] as const;
/** The example whose original clip's first frame the window shows (Genjutsu's Character swap example, src/lib/examples). */
diff --git a/tests/e2e/home-bento.mjs b/tests/e2e/home-bento.mjs
index 20197bff..2a13527a 100644
--- a/tests/e2e/home-bento.mjs
+++ b/tests/e2e/home-bento.mjs
@@ -138,7 +138,9 @@ const layout = (page) =>
page.evaluate((tiles) => {
const box = (el) => {
const r = el.getBoundingClientRect();
- return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, w: r.width, h: r.height };
+ // Its title's size: the live tile, the highlight, is second only to the video tile.
+ const title = el.querySelector("[class*=title]");
+ return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, w: r.width, h: r.height, title: title ? parseFloat(getComputedStyle(title).fontSize) : 0 };
};
const h1 = document.querySelector("#home-bento h1");
const [line1, line2] = h1.querySelectorAll(":scope > span");
@@ -248,6 +250,14 @@ if (run("1"))
check(`${tag}: the video tile and the live tile under it on the first screen`, out.length === 0, first.map((t) => `${t} ${Math.round(l.tiles[t].bottom)}`).join(", ") + ` ≤ ${bottom}`);
check(`${tag}: every tile at least 44 px to tap`, TILES.every((t) => l.tiles[t].w >= 44 && l.tiles[t].h >= 44));
}
+ // The live tile is the highlight: the biggest after the video tile, its title no smaller than any but the video's.
+ const area = (t) => l.tiles[t].w * l.tiles[t].h;
+ const rest = TILES.filter((t) => t !== "video" && t !== "live" && t !== "numbers");
+ check(
+ `${tag}: the live tile second only to the video tile`,
+ rest.every((t) => area("live") > area(t) && l.tiles.live.title >= l.tiles[t].title) && area("video") > area("live"),
+ ["video", "live", ...rest].map((t) => `${t} ${Math.round(l.tiles[t].w)}x${Math.round(l.tiles[t].h)}/${l.tiles[t].title}`).join(", "),
+ );
if (v.w >= 1024) {
const out = TILES.filter((t) => l.tiles[t].bottom > l.vh || l.tiles[t].top < 0);
check(`${tag}: all eight tiles on the first screen`, out.length === 0, out.join(", "));
diff --git a/tests/home-bento.test.ts b/tests/home-bento.test.ts
index 5593ee7a..cdad254d 100644
--- a/tests/home-bento.test.ts
+++ b/tests/home-bento.test.ts
@@ -85,7 +85,7 @@ describe("Home's first screen", () => {
}
});
- it("plays Genjutsu's group swap in the widths its render covers, cut as it is (no crossfade), beside the original", () => {
+ it("plays Genjutsu's group swap in the widths its render covers, faded out before it loops (no crossfade), beside the original", () => {
const g = bento.genjutsu;
expect(g.id).toBe(BENTO_GENJUTSU.id);
// Its own id in the playback store: the studio's card lower down may play the same cover.
@@ -94,8 +94,8 @@ describe("Home's first screen", () => {
for (const c of g.clips) {
expect(c.src).toMatch(new RegExp(`^/previews/home/genjutsu-${c.w}\\.mp4\\?v=[0-9a-f]{8}$`));
expect(mp4Size(file(c.src))).toEqual({ w: c.w, h: (c.w * 3) / 4 });
- // Five seconds of the take (120 frames at 24 fps), looped as it is.
- expect(mp4Seconds(file(c.src))).toBeCloseTo(5, 1);
+ // Five seconds of the take (120 frames at 24 fps), then its last frame held a third of a second as it fades out.
+ expect(mp4Seconds(file(c.src))).toBeCloseTo(128 / 24, 1);
}
expect(g.poster.avif.map((a) => a.w)).toEqual([...BENTO_GENJUTSU_WIDTHS]);
for (const a of g.poster.avif) expect(a.src).toMatch(new RegExp(`^/previews/home/genjutsu-${a.w}\\.avif\\?v=`));
@@ -165,8 +165,9 @@ describe("Home's first screen", () => {
}
// The live tile, the next biggest, covers a 3x phone (358 px wide) and its tile on a 2x 1440 screen (405 px under cover).
for (const f of bento.live.frames) expect(Math.max(...f.avif.map((a) => a.w))).toBeGreaterThanOrEqual(Math.max(358 * 3, 405 * 2));
- // Genjutsu's clip is its render's own 1024 px, never made up past that: a 2x laptop's tile (376 px) gets it.
- expect(pickWidth(bento.genjutsu.clips, 376 * 2).w).toBe(1024);
+ // Genjutsu's clip is never made up past its render's own 1024 px: a 2x laptop's tile (376 px) gets 768, a 3x phone 1024.
+ expect(pickWidth(bento.genjutsu.clips, 376 * 2).w).toBe(768);
+ expect(pickWidth(bento.genjutsu.clips, 358 * 3).w).toBe(1024);
// The original's window (at most 132 px) is covered on a 3x screen.
expect(Math.max(...bento.genjutsu.original.avif.map((a) => a.w))).toBeGreaterThanOrEqual(132 * 3);
});