From 3556791d5f740fd3b9211737bac57221ab3c2177 Mon Sep 17 00:00:00 2001 From: tinygusie2 Date: Tue, 29 Sep 2026 16:35:57 +0200 Subject: [PATCH 1/7] Editor: keyframes, Whisper captions, clip sound, silence and word cutting, project removal Keyframes and transitions - Clip keyframes (x, y, scale, rotation, opacity, easing) with a section in the clip inspector, diamonds on the timeline and a keyframe at the cut when splitting. - Four more transitions: slide up, blur dissolve, flash, spin. Speech recognition (Whisper) - Captions from an audio track or from the sound of the clips, on the user's own computer. Windows installs a pinned whisper.cpp release and a model on request (sha256 checked); elsewhere it is set in Settings. - Caption blocks keep exact word times (wo); split, move and text fixes keep them. - Long silences are taken out before recognition and the times mapped back, since Whisper stretches the first word after a silence over it. Clip sound, cutting - Uploads keep their sound; a clip plays it with sound: true (volume vol). - Cut silence from a clip and cut words picked from the captions; both close up every track through cutRanges (src/edit.mjs) and can be undone. Projects - Take a project off the list, or move it to the recycle bin (app only). Docs and tests cover all of it. Co-Authored-By: Claude Sonnet 5.5 --- README.md | 11 ++- docs/ARCHITECTURE.md | 68 ++++++++++++++- main.mjs | 2 +- src/captions.mjs | 51 ++++++++++- src/edit.mjs | 93 ++++++++++++++++++++ src/keyframes.mjs | 65 ++++++++++++++ src/server.mjs | 139 ++++++++++++++++++++++++++++-- src/silence.mjs | 60 +++++++++++++ src/template.mjs | 30 ++++++- src/whisper.mjs | 118 +++++++++++++++++++++++++ test/captions.test.mjs | 31 +++++++ test/edit.test.mjs | 76 +++++++++++++++++ test/keyframes.test.mjs | 36 ++++++++ test/server.test.mjs | 35 ++++++++ test/template.test.mjs | 17 +++- test/ui/editor.test.mjs | 110 +++++++++++++++++++++++- test/whisper.test.mjs | 40 +++++++++ ui/editor.css | 19 +++++ ui/editor.js | 185 ++++++++++++++++++++++++++++++++++++++-- ui/i18n.js | 33 +++++++ ui/index.html | 12 +++ ui/player.js | 1 + 22 files changed, 1200 insertions(+), 32 deletions(-) create mode 100644 src/edit.mjs create mode 100644 src/keyframes.mjs create mode 100644 src/silence.mjs create mode 100644 src/whisper.mjs create mode 100644 test/edit.test.mjs create mode 100644 test/keyframes.test.mjs create mode 100644 test/whisper.test.mjs diff --git a/README.md b/README.md index f5a04a6..7ff5f26 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,13 @@ tablet, browser window or full screen) and animates everything around them: filled with your own clips so you start from a finished video instead of an empty timeline - **Headlines** that rise in word by word, with an accent color (`*like this*`) - **Callouts** with icons, counters and a live dot, dragged into place on the preview +- **Transitions** between clips (crossfade, slide, whip, zoom, blur, flash, spin) and **keyframes** to move, scale, + rotate and fade a clip over time +- **Talking-head edits**: keep a clip's sound, **cut the silences** out of it in one click, and **cut words** + out of the video by clicking them in the captions - **Zooms** onto a point you click, and **taps / clicks** that show where to look -- **Captions** in four styles (pop, karaoke, block, classic), made from the voice-over or imported from `.srt`/`.vtt` +- **Captions** in four styles (pop, karaoke, block, classic), made from the voice-over, from any audio track with + **speech recognition** (Whisper, on your own computer, every word at its exact moment) or imported from `.srt`/`.vtt` - **Voice-over** from text (Kokoro / Piper TTS), plus a **music bed** that fades, ducks under the voice and carves an EQ pocket for it, so speech stays clear while the music stays full - **Beat detection**: snap cuts and callouts to the music @@ -108,10 +113,10 @@ Everything below is open for grabs. Comment on (or open) an issue so others know **Bigger features** - 🍎 **macOS and Linux builds**: the code is cross-platform, but packaging and testing aren't there yet -- 🎙️ **Exact word timing** for captions with Whisper (`hyperframes transcribe`) instead of estimates +- 🎙️ **Whisper on macOS and Linux**: Windows installs whisper.cpp by itself, elsewhere it has to be installed by hand - 🧪 **More tests**: the modules (`npm test`) and the timeline basics (`npm run test:ui`) are covered; rendering and most of the inspector aren't yet -- 🎞️ **Transitions between clips**: crossfades, slides and whip pans on the device screen +- 🎞️ **Keyframes on more than clips**: callouts, headlines and the device - 🖼️ **Templates**: save a video as a reusable starting point for the next one Found a bug? [Open an issue](https://github.com/tinygusie2/motion-studio/issues/new/choose). Have an idea? diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 35c83f8..2c77b5b 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -37,6 +37,9 @@ http://localhost:3400. That's the quickest way to develop the UI. - `src/template.mjs`: the composition (HTML, CSS and the GSAP timeline), the layouts, the formats and clip placement. - `src/audio.mjs`: the music bed mix (fades, ducking under the voice) as a HyperFrames volume lane. It is shared with the UI at `/lib/audio.mjs`. +- `src/keyframes.mjs`: clip keyframes (easings, interpolation, the GSAP plan). It is shared with the UI at `/lib/keyframes.mjs`. +- `src/edit.mjs`, `src/silence.mjs`: cutting time out of a video, and finding silences. Shared with the UI at `/lib/edit.mjs` and `/lib/silence.mjs`. +- `src/whisper.mjs`: finding, installing and running whisper.cpp for speech recognition. - `src/captions.mjs`: captions (word timing, grouping, splitting, SRT/VTT). It is shared with the UI at `/lib/captions.mjs`. - `ui/editor.js`: the editor (timeline, inspector, library, dialogs, keyboard). @@ -61,13 +64,16 @@ or when the rows change shape. ## Projects (workspaces) -Every project is a folder. Motion Studio can switch between them (Bestand → Projecten, Ctrl+O). +Every project is a folder. Motion Studio can switch between them (Bestand → Projecten, Ctrl+O). In that dialog a +project can be taken off the list (`POST /api/workspace/remove`, the folder stays) or, in the app, moved to the +recycle bin (`trash: true`, through the `trash` function `main.mjs` passes to `startServer`; only folders with a +`studio.json`, and the server refuses when it has no such function). The open project gives way to the next one on the list. | Path | What | | --- | --- | | `studio.json` | `{ name, defaultBrand }` | | `brands/.json` | name, url, lang, `logo` (file in `assets/brand/`), `font` (file in `assets/fonts/`), `theme` colors, `chipColors`, `pills`, `endNameSize`, `renderPrefix`, `css`, `captions` (default caption style) | -| `specs/.json` | one video: `brand`, `layout`, `dur`, `end`, `heads`, `clips` (each with `tr`/`trDur` for its transition), `clips2`, `chips`, `zooms`, `taps`, `markers`, `vo`, `audio`, `audioVol`, `music`, `subs`, `captions`, `formats`, `tagline` | +| `specs/.json` | one video: `brand`, `layout`, `dur`, `end`, `heads`, `clips` (each with `tr`/`trDur` for its transition, `kf` for its keyframes and `sound`/`vol` for its own sound), `clips2`, `chips`, `zooms`, `taps`, `markers`, `vo`, `audio`, `audioVol`, `music`, `subs`, `captions`, `formats`, `tagline` | | `assets/clips/` | screen recordings (converted to H.264 on upload) and screenshots (png/jpg); deleted files go to `.trash/` | | `assets/vo/` | audio (voice and music); generated voice-overs land here; deleted files go to `.trash/` | | `renders/` | finished MP4s (`-[-4x5\|-1x1\|-16x9].mp4`), plus a `.srt` when the video has captions | @@ -107,6 +113,25 @@ voice-over lines (automatically after the first voice-over, or via "Uit voice-ov or blocks added by hand. Word times inside a block are estimated from word length, so moving a block's in or out point re-times its words. +A block made by speech recognition also has `wo`: each word's start in seconds after the block's start. Those exact +times are used while the text still has as many words (fixing a typo keeps them, rewriting the sentence falls back +to the estimate), they move with the block, and splitting a block splits them too (`timeWords`, `splitSub`). + +### Speech recognition + +*Captions → Uit audio* (or the Edit menu) runs [whisper.cpp](https://github.com/ggml-org/whisper.cpp) on the +video's voice/audio track (`POST /api/transcribe/`, a job like render and voice-over). `src/whisper.mjs` finds +`whisper-cli` and a model (Settings `whisperCli` / `whisperModelFile` / `whisperModel`, then +`~/.motion-studio/whisper/`, then PATH). When they are missing the editor asks first and then runs +`POST /api/whisper/install`: a pinned whisper.cpp release (Windows x64 only; elsewhere install it yourself) and a +ggml model from Hugging Face, checked against the sha256 Hugging Face publishes. Nothing is downloaded before the +user agrees, and the audio never leaves the computer. + +The server converts the audio to 16 kHz mono with ffmpeg, runs `whisper-cli … -ml 1 -sow -oj` (one word per entry) +with automatic language detection, and caches the JSON per file version, model and language in `vo/whisper/`. +`wordsFromWhisper()` and `subsFromWords()` in `src/captions.mjs` turn that into caption blocks (new block after a +pause, after a sentence end, or when it gets long). The job returns the blocks; the editor puts them in the spec +with `commit`, so undo works. The style comes from `captionDefaults` < `brand.captions` < `video.captions`. It covers: - `style` (`pop`, `karaoke`, `box`, `plain`) @@ -157,13 +182,50 @@ enlarged. The ideal source size is twice the screen size. ## Clip transitions -By default one clip cuts hard to the next. A clip's `tr` (`fade`, `slide`, `whip` or `zoom`, see `transitions` in +By default one clip cuts hard to the next. A clip's `tr` (`fade`, `slide`, `slideup`, `whip`, `zoom`, `blur`, `flash` or `spin`, see `transitions` in `src/template.mjs`) and optional `trDur` (seconds) set how it comes in. The cut stays at the incoming clip's `start`: the clip that was showing there (or ended at most 0.1 s before) is held on screen `trDur` seconds longer, by extending its `data-duration`, and both animate on the GSAP timeline while they overlap. Clips then stack by their start, so the incoming one is on top. Without a clip before it, the clip only animates in over the screen background. `clipTransitions()` plans this per device. +## Clip sound and cutting + +Uploaded videos keep their sound (AAC). A clip plays it when it has `sound: true` (`vol`, 0..1, is its level): the +`