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.

Exact frames: wait for a video's pending seek before seeking it again (#3)

riverisbuilding6dee7cd4e9bb
diff --git a/packages/openfilm/CHANGELOG.md b/packages/openfilm/CHANGELOG.md
index c6bade1..26fe705 100644
--- a/packages/openfilm/CHANGELOG.md
+++ b/packages/openfilm/CHANGELOG.md
@@ -7,6 +7,9 @@
- f486188: Windows: an ffmpeg that is stopped (a cancelled render or export, a mix that runs too long) ends with the real ffmpeg
behind a Chocolatey or Scoop shim; a name with a `:` is cleaned on import, rename and new folders as on macOS and
Linux, not refused; Studio's supervisor opens the null device by its Windows name.
+- A render or `look` frame of a video clip woken ahead of its cut waits for the seek it was woken with before its own:
+ on a slow machine the frame showed the clip's first second instead of the one asked for, and `look` said the same t
+ drew two pictures.
## 0.1.3
diff --git a/packages/openfilm/src/timeline.mjs b/packages/openfilm/src/timeline.mjs
index 82045a9..ac121fa 100644
--- a/packages/openfilm/src/timeline.mjs
+++ b/packages/openfilm/src/timeline.mjs
@@ -183,6 +183,9 @@ const SAME_TIME = 1e-4; // s: a video's currentTime is kept to the microsecond,
* moment the new frame is presented.
*/
async function showVideoAt(v, t) {
+ /* a seek still under way (the start a video was woken at, see wake): its `seeked` and its frame would be taken for
+ this one's, and the picture captured was the earlier time's */
+ 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;