Skip to content

The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.

Render: on Windows, a film whose video never shows is drawn again another way; Direct3D asked for by name (#247)

riverisbuilding6fb7e83e20d1
diff --git a/.changeset/video-not-shown-redraw.md b/.changeset/video-not-shown-redraw.md
new file mode 100644
index 0000000..ab2322b
--- /dev/null
+++ b/.changeset/video-not-shown-redraw.md
@@ -0,0 +1,5 @@
+---
+"openfilm": patch
+---
+
+Exports on Windows: when Vulkan doesn't show video, OpenFilm now asks for Direct3D by name. Before, it fell back to Chromium's default, which on Windows draws on the CPU. And when a film's video frames never show in the browser drawing it, though the check made at startup passed, the export is drawn again in browsers that show video another way, instead of running for hours to make a black video. The export tray keeps the time left in view when its line is too long.
diff --git a/packages/openfilm/bin/openfilm.mjs b/packages/openfilm/bin/openfilm.mjs
index 984097c..ef55a57 100755
--- a/packages/openfilm/bin/openfilm.mjs
+++ b/packages/openfilm/bin/openfilm.mjs
@@ -160,7 +160,12 @@ if (RAW[0] === 'get') {
while nothing else wants it */
render: () => {
try { setPriority(10); } catch { /* not allowed here: as it is */ }
- return import('../src/render.mjs').then((m) => m.render(args, opts));
+ /* a film whose video this browser never showed is drawn once more, in browsers that show video another way */
+ return import('../src/render.mjs').then((m) => m.render(args, opts).catch(async (e) => {
+ if (!(e instanceof (await import('../src/host.mjs')).VideoNotShown)) throw e;
+ console.error(`openfilm: ${e.message}: drawn again`);
+ return m.render(args, opts);
+ }));
},
update: () => import('../studio/client.mjs').then((m) => m.updateOpenfilm((line) => console.error(line))),
skills: () => import('../src/skills-cli.mjs').then((m) => m.skillsCommand(RUN)),
diff --git a/packages/openfilm/src/browser-pool.mjs b/packages/openfilm/src/browser-pool.mjs
index 53f6ec1..136c59b 100644
--- a/packages/openfilm/src/browser-pool.mjs
+++ b/packages/openfilm/src/browser-pool.mjs
@@ -77,9 +77,9 @@ export class BrowserPool {
/**
* What a browser that crashed, or a tab that stopped answering, says: drawn again in new browsers, it may work. Also a
* page or a file the browser could not load from Studio for want of the system's network buffers (Windows: a moment's
- * shortage, not the page's fault).
+ * shortage, not the page's fault). And a film whose video frames its browser never showed (host.mjs VideoNotShown).
*/
-const BROWSER_FAILED = /browser drawing the page closed|target (page, context or browser has been )?closed|target crashed|page crashed|browser has been closed|browser (has )?disconnected|did not finish within|did not come within|net::ERR_NO_BUFFER_SPACE/i;
+const BROWSER_FAILED = /browser drawing the page closed|target (page, context or browser has been )?closed|target crashed|page crashed|browser has been closed|browser (has )?disconnected|did not finish within|did not come within|net::ERR_NO_BUFFER_SPACE|video is shown another way from now on/i;
/**
* Whether a render that failed is worth drawing again in new browsers: its browser crashed or stopped answering. A
diff --git a/packages/openfilm/src/host.d.mts b/packages/openfilm/src/host.d.mts
index 33779ce..59c5ba5 100644
--- a/packages/openfilm/src/host.d.mts
+++ b/packages/openfilm/src/host.d.mts
@@ -9,7 +9,7 @@ export declare function launch(opts?: LaunchOptions): Promise<Browser>;
/** A renderer string that is not a GPU: WebGL drawn on the CPU. */
export declare const SOFTWARE_GL: RegExp;
/** Windows: open with Vulkan once, and keep it only when its renderer is a GPU and it shows videos; otherwise the GPU another way, or Chromium's default. */
-export declare function vulkanFirst(renderer?: (browser: Browser) => Promise<string>, presents?: (browser: Browser) => Promise<boolean>): (open: (angle: string[]) => Promise<Browser>) => Promise<Browser>;
+export declare function vulkanFirst(renderer?: (browser: Browser) => Promise<string>, presents?: (browser: Browser) => Promise<boolean>): ((open: (angle: string[]) => Promise<Browser>) => Promise<Browser>) & { videoNotShown(): Promise<boolean> };
/** Whether the browser shows the frame a paused video is sought to, for H.264 and HEVC (some Windows computers with Vulkan do not). */
export declare function presentsVideo(browser: Browser): Promise<boolean>;
/** Close every browser launch() opened that is still open: what waits on one fails at once instead of never answering. */
@@ -17,13 +17,17 @@ export declare function closeBrowsers(): Promise<void>;
/** With `offline`: the origins still open to a page, and optionally who answers them (a cache). */
export interface PageNetwork { allow?: readonly string[]; fetch?(url: string, headers: Record<string, string>): Promise<{ status: number; headers: Record<string, string>; body: Buffer }> }
export declare class FrameError extends Error {}
+/** A film whose video frames this browser never showed, drawn again in browsers that show video another way. */
+export declare class VideoNotShown extends FrameError {}
+/** A film's video frames were never seen: on Windows, browsers opened from now on show video another way. Whether they will. */
+export declare function videoNotShown(): Promise<boolean>;
/** A page's facts once ready: its length (null: it has no end), and its viewport (its own size, or 1920 × 1080 when it says none). */
/** `sized`: the page sets its own width and height (without, it is laid out at its clip's size or the stage's). */
export interface FilmMeta { duration: number | null; width: number; height: number; sized: boolean; sounds: FilmSound[] }
/** One sound of the film as the built-in timeline plays it: `src` a path on the film's origin, placed at film second `at`, its source seconds [from, to). */
export interface FilmSound { clip: string; src: string; at: number; from: number; to?: number; volume: number; speed: number }
export declare class FilmPage {
- static open(browser: Browser, origin: string, entry: string, opts?: { scale?: number; size?: { w: number; h: number } | null; transparent?: boolean; black?: boolean; readyMs?: number; offline?: boolean; network?: PageNetwork; waitMs?: number }): Promise<FilmPage>;
+ static open(browser: Browser, origin: string, entry: string, opts?: { scale?: number; size?: { w: number; h: number } | null; transparent?: boolean; black?: boolean; readyMs?: number; offline?: boolean; network?: PageNetwork; waitMs?: number; onVideoNotShown?: () => Promise<boolean> }): Promise<FilmPage>;
page: Page;
meta: FilmMeta;
problems: Array<{ kind: string; message: string }>;
diff --git a/packages/openfilm/src/host.mjs b/packages/openfilm/src/host.mjs
index e5a1d47..1b3fafc 100644
--- a/packages/openfilm/src/host.mjs
+++ b/packages/openfilm/src/host.mjs
@@ -355,17 +355,19 @@ const deviceOf = (/** @type {string} */ renderer) => {
* CI runner or a computer without a Vulkan driver has none, so the first browser reads its renderer once: when Vulkan
* did not start, or is software too, it and every later browser take Chromium's default.
*
- * Vulkan on a GPU may still never show a video's frames (presentsVideo). Then the default is taken when it reaches the
- * same GPU (a computer with one), else Vulkan with videos decoded on the CPU; each only when it shows them. When
- * neither does, the default.
+ * Vulkan on a GPU may still never show a video's frames (presentsVideo). Then Direct3D is taken when it reaches the
+ * same GPU (a computer with one), else Vulkan with videos decoded on the CPU, else Direct3D on the other GPU; each only
+ * when it shows them. When none does, the default.
* @param {(browser: import('playwright-core').Browser) => Promise<string>} [renderer]
* @param {(browser: import('playwright-core').Browser) => Promise<boolean>} [presents]
*/
export function vulkanFirst(renderer = rendererOf, presents = presentsVideo) {
/** @type {Promise<string[]> | null} what every browser after the first is opened with */
let chosen = null;
+ /* false once a film's videos were never seen in Vulkan's browsers (videoNotShown): its check is not trusted again */
+ let vulkanVideo = true;
/** @param {(angle: string[]) => Promise<import('playwright-core').Browser>} open */
- return async (open) => {
+ const pick = async (open) => {
if (chosen) return open(await chosen);
/** @type {(angle: string[]) => void} */
let choose = () => {};
@@ -380,30 +382,58 @@ export function vulkanFirst(renderer = rendererOf, presents = presentsVideo) {
choose([]);
return open([]);
}
- if (await shows(browser)) {
+ if (vulkanVideo && await shows(browser)) {
choose(vulkan);
return browser;
}
await browser.close().catch(() => {});
- const fallback = await open([]);
- if (deviceOf(gpu) != null && deviceOf(await read(fallback)) === deviceOf(gpu) && await shows(fallback)) {
- choose([]);
- return fallback;
+ /* Direct3D, asked for by name (the default is SwiftShader, on the CPU): first on the same GPU, a computer with one */
+ const d3d11 = ['--use-angle=d3d11'];
+ const direct = await open(d3d11).catch(() => null);
+ const directGpu = direct ? await read(direct) : 'none';
+ /** @type {boolean | null} */
+ let directShows = null;
+ const directShown = async () => (directShows ??= Boolean(direct) && await shows(/** @type {import('playwright-core').Browser} */ (direct)));
+ if (deviceOf(gpu) != null && deviceOf(directGpu) === deviceOf(gpu) && await directShown()) {
+ choose(d3d11);
+ return /** @type {import('playwright-core').Browser} */ (direct);
}
+ /* then Vulkan with videos decoded on the CPU: pages stay on its GPU, the discrete one on a laptop with two (#64) */
const decoded = [...vulkan, '--disable-accelerated-video-decode'];
const cpu = await open(decoded).catch(() => null);
if (cpu && await shows(cpu)) {
- await fallback.close().catch(() => {});
+ await direct?.close().catch(() => {});
choose(decoded);
return cpu;
}
await cpu?.close().catch(() => {});
+ /* then Direct3D on the other GPU, still not the CPU */
+ if (direct && directGpu !== 'none' && !SOFTWARE_GL.test(directGpu) && await directShown()) {
+ choose(d3d11);
+ return direct;
+ }
+ await direct?.close().catch(() => {});
choose([]);
- return fallback;
+ return open([]);
+ };
+ /**
+ * A film's video frames were never seen in browsers opened with Vulkan, though its check passed (footage it does
+ * not tell, as the check's clips do): the browsers opened from now on take the next way. Whether there was one.
+ */
+ pick.videoNotShown = async () => {
+ const was = chosen && await chosen;
+ if (!was || was.join() !== '--use-angle=vulkan') return false;
+ vulkanVideo = false;
+ chosen = null;
+ return true;
};
+ return pick;
}
const onWindows = vulkanFirst();
+/** A film's video frames were never seen (FilmPage.seek): on Windows, browsers opened from now on show video another way. */
+export const videoNotShown = () => (process.platform === 'win32' ? onWindows.videoNotShown() : Promise.resolve(false));
+
/** Every browser launch() opened and that is still open. */
const LIVE = new Set();
/** Close them all: what waits on one (a render, a poster) fails at once instead of never answering. */
@@ -426,6 +456,10 @@ const CAPTURE_MS = 30_000;
/** A frame that threw inside the page: the film's fault, reported as such rather than as a crash of the tool. */
export class FrameError extends Error {}
+/** A film whose video frames this browser never showed, drawn again in browsers that show video another way. */
+export class VideoNotShown extends FrameError {}
+/** How many exact frames of video may go unseen, none seen yet, before the browser counts as showing no video. */
+const UNSEEN_VIDEO = 3;
/**
* `work`, or a FrameError saying `why` once `ms` pass. The limit is kept here, not in the page: a page whose code
@@ -469,9 +503,10 @@ const stuck = async (/** @type {import('playwright-core').Page} */ page) =>
/** One web page in one browser tab. */
export class FilmPage {
- static async open(browser, origin, entry, { scale = 1, size = null, transparent = false, black = false, offline = false, network = {}, waitMs = 10_000, readyMs = READY_MS } = {}) {
+ static async open(browser, origin, entry, { scale = 1, size = null, transparent = false, black = false, offline = false, network = {}, waitMs = 10_000, readyMs = READY_MS, onVideoNotShown = videoNotShown } = {}) {
const film = new FilmPage();
film.problems = [];
+ film.onVideoNotShown = onVideoNotShown;
film.browser = browser;
film.origin = origin;
film.entry = entry;
@@ -586,6 +621,7 @@ export class FilmPage {
: null));
// two frames: the first commits style and layout, the second lets layers (filters, 3D) finish rasterizing
await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r())));
+ return window.__filmVideos?.() ?? null;
}, t).catch((e) => {
const why = String(e.message).replace(/^page\.evaluate: /, '').split('\n')[0].replace(/^Error: /, '');
/* files that failed, by their path in the folder, once, and not the ones the reason names already */
@@ -597,7 +633,12 @@ export class FilmPage {
throw new FrameError(`${said}${failed.length ? ` (failed to load: ${failed.join(', ')})` : ''}`);
});
const why = `frame(${Number(t.toFixed(3))}) did not finish within ${timeoutMs / 1000} s`;
- await inTime(drawn, timeoutMs, why).catch(async (e) => { throw e.message === why ? new FrameError(`${why}${await stuck(this.page)}`) : e; });
+ const videos = await inTime(drawn, timeoutMs, why).catch(async (e) => { throw e.message === why ? new FrameError(`${why}${await stuck(this.page)}`) : e; });
+ /* every seek waited out (five seconds a frame) and the picture black: when browsers can show video another way,
+ the film is drawn again in those */
+ if (videos && videos.shown === 0 && videos.unshown >= UNSEEN_VIDEO && await this.onVideoNotShown()) {
+ throw new VideoNotShown(`this browser never showed the film's video frames (${videos.unshown} sought): video is shown another way from now on`);
+ }
}
/** PNG (or JPEG) of the viewport as composited. */
diff --git a/packages/openfilm/src/host.test.mjs b/packages/openfilm/src/host.test.mjs
index d03ee5c..2f8fe2b 100644
--- a/packages/openfilm/src/host.test.mjs
+++ b/packages/openfilm/src/host.test.mjs
@@ -178,43 +178,68 @@ test('Windows: Vulkan when its renderer is a GPU, read once; otherwise the defau
assert.equal(never.count, 0);
});
-test('Windows: when Vulkan never shows a video frame, the same GPU by default, else Vulkan decoding on the CPU, else the default', async () => {
+test('Windows: when Vulkan never shows a video frame, Direct3D on the same GPU, else Vulkan decoding on the CPU, else Direct3D on the other GPU, else the default', async () => {
const vulkan = ['--use-angle=vulkan'];
+ const d3d11 = ['--use-angle=d3d11'];
const cpu = [...vulkan, '--disable-accelerated-video-decode'];
const nvidia = 'ANGLE (NVIDIA, Vulkan 1.4.329 (NVIDIA GeForce RTX 4050 Laptop GPU (0x000028A1)), NVIDIA)';
const nvidiaD3d = 'ANGLE (NVIDIA, NVIDIA GeForce RTX 4050 Laptop GPU (0x000028A1) Direct3D11 vs_5_0 ps_5_0, D3D11)';
const intelD3d = 'ANGLE (Intel, Intel(R) UHD Graphics (0x0000A7A8) Direct3D11 vs_5_0 ps_5_0, D3D11)';
- /** Browsers by what they are opened with: the default's renderer, and which ones show a video's frames. */
- const machine = (/** @type {string} */ fallbackGpu, /** @type {string[][]} */ showing) => {
+ const swiftShader = 'ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)';
+ /** Browsers by what they are opened with: Direct3D's renderer, and which ones show a video's frames. */
+ const machine = (/** @type {string} */ direct, /** @type {string[][]} */ showing) => {
const opened = /** @type {string[][]} */ ([]), closed = /** @type {string[][]} */ ([]);
const open = async (/** @type {string[]} */ angle) => {
opened.push(angle);
return /** @type {any} */ ({ angle, close: async () => { closed.push(angle); } });
};
- const renderer = async (/** @type {any} */ b) => (b.angle.length ? nvidia : fallbackGpu);
+ const renderer = async (/** @type {any} */ b) => (b.angle[0] === '--use-angle=vulkan' ? nvidia : b.angle.length ? direct : swiftShader);
const presents = async (/** @type {any} */ b) => showing.some((a) => a.join() === b.angle.join());
return { pick: vulkanFirst(renderer, presents), open, opened, closed };
};
- /* one GPU: D3D11 reaches it and shows the frames */
- let m = machine(nvidiaD3d, [[]]);
- assert.deepEqual((await m.pick(m.open)).angle, []);
- assert.deepEqual((await m.pick(m.open)).angle, []);
- assert.deepEqual(m.opened, [vulkan, [], []]);
+ /* one GPU: Direct3D reaches it and shows the frames */
+ let m = machine(nvidiaD3d, [d3d11]);
+ assert.deepEqual((await m.pick(m.open)).angle, d3d11);
+ assert.deepEqual((await m.pick(m.open)).angle, d3d11);
+ assert.deepEqual(m.opened, [vulkan, d3d11, d3d11]);
assert.deepEqual(m.closed, [vulkan]);
- /* two GPUs (#64): the default is the integrated one, so Vulkan stays, its videos decoded on the CPU */
- m = machine(intelD3d, [[], cpu]);
+ /* two GPUs (#64): Direct3D takes the integrated one, so Vulkan stays, its videos decoded on the CPU */
+ m = machine(intelD3d, [d3d11, cpu]);
assert.deepEqual((await m.pick(m.open)).angle, cpu);
assert.deepEqual((await m.pick(m.open)).angle, cpu);
- assert.deepEqual(m.opened, [vulkan, [], cpu, cpu]);
- assert.deepEqual(m.closed, [vulkan, []]);
+ assert.deepEqual(m.opened, [vulkan, d3d11, cpu, cpu]);
+ assert.deepEqual(m.closed, [vulkan, d3d11]);
+
+ /* only Direct3D on the integrated GPU shows them: that, rather than the CPU */
+ m = machine(intelD3d, [d3d11]);
+ assert.deepEqual((await m.pick(m.open)).angle, d3d11);
+ assert.deepEqual(m.opened, [vulkan, d3d11, cpu]);
+ assert.deepEqual(m.closed, [vulkan, cpu]);
- /* nothing shows them: the default, as without a GPU */
+ /* nothing shows them: the default */
m = machine(intelD3d, []);
assert.deepEqual((await m.pick(m.open)).angle, []);
- assert.deepEqual(m.opened, [vulkan, [], cpu]);
- assert.deepEqual(m.closed, [vulkan, cpu]);
+ assert.deepEqual(m.opened, [vulkan, d3d11, cpu, []]);
+ assert.deepEqual(m.closed, [vulkan, cpu, d3d11]);
+});
+
+test('Windows: a film whose video Vulkan never showed, though its check passed, moves every later browser to the next way, once', async () => {
+ const vulkan = ['--use-angle=vulkan'];
+ const opened = /** @type {string[][]} */ ([]);
+ const open = async (/** @type {string[]} */ angle) => { opened.push(angle); return /** @type {any} */ ({ angle, close: async () => {} }); };
+ const renderer = async (/** @type {any} */ b) => (b.angle.length
+ ? 'ANGLE (NVIDIA, Vulkan 1.4.329 (NVIDIA GeForce RTX 4050 Laptop GPU (0x000028A1)), NVIDIA)'
+ : 'ANGLE (NVIDIA, NVIDIA GeForce RTX 4050 Laptop GPU (0x000028A1) Direct3D11 vs_5_0 ps_5_0, D3D11)');
+ const pick = vulkanFirst(renderer, async () => true);
+ assert.deepEqual((await pick(open)).angle, vulkan);
+ assert.equal(await pick.videoNotShown(), true);
+ /* Direct3D on the same GPU, its check not asked of Vulkan again */
+ assert.deepEqual((await pick(open)).angle, ['--use-angle=d3d11']);
+ assert.deepEqual((await pick(open)).angle, ['--use-angle=d3d11']);
+ assert.deepEqual(opened, [vulkan, vulkan, ['--use-angle=d3d11'], ['--use-angle=d3d11']]);
+ assert.equal(await pick.videoNotShown(), false, 'no other way left to move to');
});
test('a browser shows a paused video\'s frame once sought; one that never presents it is told', { timeout: 60_000 }, async () => {
diff --git a/packages/openfilm/src/timeline.mjs b/packages/openfilm/src/timeline.mjs
index 54fca3f..150026d 100644
--- a/packages/openfilm/src/timeline.mjs
+++ b/packages/openfilm/src/timeline.mjs
@@ -171,7 +171,7 @@ const SEEK_TRIES = 3;
* moment the new frame is presented. Knowing how long the video's frames last (`frame`, from the host), the frame for t
* is told by its time: the old frame, shown again as its video turns visible, is not taken for it, even after the seek
* is done. Not knowing, a frame presented before the seek is done is taken for the old one when it is nearer where the
- * video was.
+ * video was. Whether the frame was seen on screen (false: every try ran out).
*/
async function showVideoAt(v, t, frame = null) {
/* a seek still under way (the start a video was woken at, see wake): its `seeked` and its frame would be taken for
@@ -179,7 +179,7 @@ async function showVideoAt(v, t, frame = null) {
if (v.seeking) await new Promise((done) => { v.addEventListener('seeked', done, { once: true }); setTimeout(done, 10000); });
/* the same time again (to the microsecond the element keeps): no seek, nothing new to present (a seek there would
present nothing, and the wait would run out) */
- if (!v.seeking && Math.abs(v.currentTime - t) < SAME_TIME && v.readyState >= 2) return;
+ if (!v.seeking && Math.abs(v.currentTime - t) < SAME_TIME && v.readyState >= 2) return true;
const before = v.currentTime;
let sought = false;
/* the frame a seek to t lands in starts at most a frame before t (and the seek goes a millisecond in, see host.mjs),
@@ -213,10 +213,13 @@ async function showVideoAt(v, t, frame = null) {
const shown = presented ? await presented : true;
clearTimeout(timer);
if (handle) v.cancelVideoFrameCallback?.(handle);
- if (shown || last) return;
+ if (shown || last) return shown;
}
}
+/** Exact frames of video clips seen on screen, and ones never seen (a host tells a browser that shows no video by it). */
+const videoSeen = { shown: 0, unshown: 0 };
+
/**
* Every video a page moved in its frame, until its new frame is on screen (SPEC §4: a host waits for pending seeks):
* decoded (`seeked`), then presented (the frame callback), each with a time limit so a stalled video cannot hold the
@@ -971,7 +974,9 @@ async function drawClip(c, t, live, play, turn, coming, going) {
be presented, yet the picture keeps the frame it had for a second or so (Chromium, its frames sent apart from
the page's): the same t drew two pictures */
if (appears) await frames(2);
- await showVideoAt(c.el, want, await frameOf(c));
+ /* one without a picture (a sound in a video clip) has no frame to show */
+ if (await showVideoAt(c.el, want, await frameOf(c))) videoSeen.shown++;
+ else if (c.el.videoWidth > 0) videoSeen.unshown++;
return;
}
/* a page closed while the playhead was far (see near): opened again, then drawn; one that will not open is the
@@ -991,6 +996,8 @@ async function drawClip(c, t, live, play, turn, coming, going) {
override(c, c.preview ?? c.overrides);
}
+window.__filmVideos = () => ({ ...videoSeen });
+
window.film = {
get duration() { return Math.max(0.001, ...clips.filter((c) => !c.hidden).map((c) => c.end)); },
width: stage.w, height: stage.h,
diff --git a/packages/openfilm/src/timeline.test.mjs b/packages/openfilm/src/timeline.test.mjs
index f9abcc4..9263c4f 100644
--- a/packages/openfilm/src/timeline.test.mjs
+++ b/packages/openfilm/src/timeline.test.mjs
@@ -5,7 +5,7 @@ import { cpSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { createServer } from 'node:http';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
-import { FilmPage, launch, serve } from './host.mjs';
+import { FilmPage, launch, serve, VideoNotShown } from './host.mjs';
import { open } from './shared.mjs';
import { filmHead, filmHtml } from './film-doc.mjs';
@@ -395,6 +395,32 @@ test('a sought frame that is decoded but never presented (a seek just after load
}
});
+test('a browser that never shows a film\'s video frames: after a few, the film is drawn again where video is shown another way, when there is one', { skip: !hasFfmpeg && 'no ffmpeg', timeout: 120_000 }, async () => {
+ const dir = footage('of-never-shown-');
+ writeFileSync(join(dir, 'film.html'), filmHtml({ stage: { w: 320, h: 180 }, tracks: [{ clips: [{ id: 'v', src: 'a.mp4', time: [0, 4] }] }] }));
+ const site = await serve(dir);
+ const browser = await launch();
+ try {
+ let asked = 0;
+ const film = await FilmPage.open(browser, site.url, 'film.html', { onVideoNotShown: async () => { asked++; return true; } });
+ await film.page.evaluate(() => { HTMLVideoElement.prototype.requestVideoFrameCallback = () => 0; });
+ await film.seek(0.5);
+ await film.seek(1.5);
+ await assert.rejects(film.seek(2.5), (e) => e instanceof VideoNotShown && /never showed the film's video frames \(3 sought\)/.test(e.message));
+ assert.equal(asked, 1);
+ assert.deepEqual(await film.page.evaluate(() => window.__filmVideos()), { shown: 0, unshown: 3 });
+ await film.close();
+ /* with no other way (not Windows, or moved already) it goes on as before */
+ const as = await FilmPage.open(browser, site.url, 'film.html', { onVideoNotShown: async () => false });
+ await as.page.evaluate(() => { HTMLVideoElement.prototype.requestVideoFrameCallback = () => 0; });
+ for (const t of [0.5, 1.5, 2.5]) await as.seek(t);
+ await as.close();
+ } finally {
+ await browser.close();
+ await site.close();
+ }
+});
+
test('watched, a still moment whose video frame is decoded but never presented (Chromium) is sought again until it shows', { skip: !hasFfmpeg && 'no ffmpeg', timeout: 60_000 }, async () => {
const dir = footage('of-unshown-watched-');
writeFileSync(join(dir, 'film.html'), filmHtml({ stage: { w: 320, h: 180 }, tracks: [{ clips: [{ id: 'v', src: 'a.mp4', at: 1, time: [0, 4] }] }] }));
diff --git a/packages/openfilm/studio/ui/src/components/export/ExportTray.tsx b/packages/openfilm/studio/ui/src/components/export/ExportTray.tsx
index 154e14c..50a49cc 100644
--- a/packages/openfilm/studio/ui/src/components/export/ExportTray.tsx
+++ b/packages/openfilm/studio/ui/src/components/export/ExportTray.tsx
@@ -233,15 +233,17 @@ function JobLine({ job, cancelling, t }: { job: ExportJob; cancelling: boolean;
job.phase ? t(`exportTray.phase.${job.phase}`) : '',
job.framesTotal ? `${job.framesDone}/${job.framesTotal}` : '',
job.rate ? `${job.rate.toFixed(job.rate < 10 ? 1 : 0)} fps` : '',
- job.etaMs != null ? `${t('exportTray.eta')} ${formatDuration(job.etaMs)}` : '',
].filter(Boolean);
+ /* how long is left never gives way: a narrow tray cuts the rest first */
+ const left = job.etaMs != null ? `${t('exportTray.eta')} ${formatDuration(job.etaMs)}` : '';
return (
<div className="mt-1.5">
<div className="h-[3px] overflow-hidden rounded-full bg-[var(--surface-2)]">
<div className="h-full rounded-full bg-[var(--text)] transition-[width] duration-500" style={{ width: `${pct}%` }} />
</div>
<p className="mt-1 flex items-center gap-1.5 text-[11px] tabular-nums text-[var(--text-faint)]">
- <span className="min-w-0 flex-1 truncate">{parts.join(' · ')}</span>
+ <span className="min-w-0 flex-1 truncate">{parts.join(' · ')}{left ? ' ·' : ''}</span>
+ {left ? <span className="shrink-0">{left}</span> : null}
{job.encoder ? <span className="shrink-0 rounded bg-[var(--surface-2)] px-1 py-px font-mono text-[10px]">{job.encoder}</span> : null}
<span className="shrink-0">{pct}%</span>
</p>