Skip to content

feat(timeline): captions track with styled, editable captions and burned-in export - #288

Merged
edenreich merged 12 commits into
mainfrom
fix/issue-279
Sep 18, 2026
Merged

edenreich merged 12 commits into
mainfrom
fix/issue-279

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #279

Summary

Adds a captions track kind to the <stem>.timeline.json contract: caption clips carry text, start, end and optional per-word words, and the track carries a style preset plus a placement - position (bottom, center, top) or x/y, the centre of the caption block as fractions of the frame, set by dragging the block on the preview. Four style presets are defined once per side as a table of size, weight, case, outline and colour (TS for the preview, Rust for the export) and rendered identically, in the looks the short-form platforms ship: classic a broadcast subtitle on a translucent box, bold a huge uppercase yellow punch line, highlight a green per-word pop that stays, karaoke a dim-to-white fill; the desktop draws the active caption over the video in the preview, burns captions into the export through a generated .ass file (subtitles= filter, with \k timing for the word presets) and writes a sidecar .srt into export/.

Captions can be created from either end: the toolbar's captions button asks the agent, which follows the new captions rules in the video-editing skill (text from the spoken clips or the whisper transcript, chunked to about 5 s), and + on the captions lane inserts a caption at the playhead to type in directly. A caption clip can also be voiced with "Speak this", which drafts a spoken audio clip for the existing TTS flow.

That + replaces the old marker button, which dropped a draft clip on whichever audio track happened to hold speech: every audio and captions lane now carries its own, and the clip it inserts never overlaps what is already on the lane.

Changes

  • frontend/lib/timeline.ts: TrackKind gains captions; captions tracks carry x/y (clamped to the frame) and moveCaptions sets or clears them; caption clips parse/serialize words; tracks carry style (unknown names fall back to the default preset) and position; CAPTION_STYLES catalogue; captionTrack helper; addEmptyClip replaces addMarker and inserts an empty clip on a named lane, skipping past a clip the playhead sits in and appending past a full lane like a dropped file; speakClip creates/updates a draft spoken clip from a caption; setClipText only marks spoken audio clips draft; spokenCount counts audio tracks only; captions lanes stack with overlays above the video.

  • frontend/components/TimelineView.tsx: the stage draws the active caption styled by the preset (word-by-word highlight/karaoke in step with the playhead), a preset select and an Add caption button on the captions lane header, Add voice clip on audio lane headers in place of the toolbar's marker button, an Add captions toolbar button that asks the agent, one captions track in the add-track row, caption clips are editable/movable/trimmable/deletable like other clips, and the clip editor gains a caption textarea plus a "Speak this" button. Media no longer drops onto a captions lane. syncMedia now pauses the clip under the playhead, so Space stops the video and not just the playhead. CaptionOverlay reads the preset table instead of branching per preset name, and the caption block drags on the stage to place it (double-click puts it back on position).

  • backend/src/timeline.rs: export_args chains subtitles=<file> onto the picture label when a captions track exists; caption_sidecars renders the track to <stem>.ass (one ASS style per preset, \an5\pos() for a dragged block, \k timing with a tag of its own for a pause before a word, uppercase for bold, bottom/center/top placement) and writes export/<stem>.srt; the audio mix no longer pulls in the captions track; the sidecars are written after the libass check; a missing subtitles (libass) filter in the chosen ffmpeg is reported as an error, not silently skipped; unit tests in the style of export_args_delays_and_mixes_every_clip.

  • .agents/skills/video-editing/SKILL.md: documents the captions track in the contract, a ## Captions section with the text sources, the ~5 s chunking rules, the presets and the whisper-cli -ml 1 pass for word timing, and the libass prerequisite.

  • Voice sample choice: the redo prompts ask which sample to clone instead of sending a fixed "with my cloned voice", and the skill gains a ## Picking the voice section - the track's voice_sample wins when the user set it on the lane header, otherwise list ~/.infer/models/tts/samples/ and ask with AskUserQuestion, one option per sample plus Random plus My voice from the recording when source_audio is transcribe, then write the pick back into voice_sample. Nothing to choose between means no question.

  • frontend/store.tsx: the content-project guidance routes "add captions" to the skill.

  • e2e/tests/captions.yaml and e2e/tests/voice-sample-choice.yaml + e2e/scenarios.yaml: the agent writes a captions track to the timeline, and a redo asks which voice sample to clone before synthesizing.

  • backend/src/gateway.rs + backend/src/process_manager.rs: start_gateway returned early whenever anything answered the gateway URL, so a force or restart was a no-op when a leaked gateway from an earlier session held the port - the new gateway could not bind, stayed up on its metrics port only, and requests kept reaching the old process with AUDIO_ENABLED unset, which is a 404 from TextToSpeech with nothing to explain it. reuse_running_gateway decides it now: a plain start still adopts a gateway the desktop does not own, a restart reports it.

  • frontend/lib/timeline.ts: trimClip clamped a clip's tail to its source length, which is right for a music or video file but not for a spoken clip - the wav is synthesized to fit a slot and is routinely shorter than it, so dragging a voice clip's right edge outwards snapped it back to the end of the speech, and its left edge would not move outwards at all. Spoken clips are exempt on both edges, and a head trim can no longer produce a negative offset.

Notes

@edenreich
edenreich marked this pull request as ready for review September 18, 2026 21:35
…e karaoke tags

A captions track fell into the audio bed, so a caption clip with a src became an ffmpeg input. The \k tags also ran back to back from the dialogue start, drifting against the preview, which times every word from its absolute start. The sidecars are now written after the libass check, not before it.
Nothing produced caption clips: the lane, the preset select and the burn-in all existed, but the only way in was hand-editing the JSON. The video-editing skill now documents the captions track, where the text comes from and the ~5 s chunking, a toolbar button asks the agent for captions, and a + on the captions lane inserts one at the playhead. spokenCount no longer counts captions as voice, and media no longer drops on a captions lane.
…tton

The marker button dropped a draft clip on whichever audio track happened to hold speech, which read as a timeline marker and behaved like neither. Each audio and captions lane now carries a + that inserts an empty clip at the playhead on that lane, selected and ready to type in. addEmptyClip replaces addMarker: it skips past a clip the playhead sits in so a lane never holds two clips at once, and appends past a full lane like a dropped file does.

Also fixes playback: syncMedia only paused media that had fallen outside its range, so Space stopped the playhead while the video and audio under it kept playing.
The four presets differed only in word colouring, so they read as one look. They now carry size, weight, case, outline and colour in one table per side - a broadcast subtitle on a box, a huge uppercase yellow punch line, a green per-word pop and a dim-to-white karaoke fill - and the preview reads that table instead of branching per name.

Captions are also placed by dragging the block on the preview: the track gains x/y, the centre of the block as fractions of the frame, which the export burns in as an5 pos() and which win over position. Double-clicking the block clears them.
…e silently

Redo sent a fixed "with my cloned voice" prompt, so the sample was whatever the agent had settled on and there was no way to change it - the lane header's sample select only appears once a track already holds speech. The redo prompts now ask for the sample, and the skill gains a Picking the voice section: list the library, ask with AskUserQuestion, one option per sample plus Random plus the recording itself when source_audio is transcribe, and write the pick back into voice_sample.
…he restart

Enabling text to speech saves the config and restarts the gateway so AUDIO_ENABLED reaches it, but start_gateway returned early whenever anything answered the gateway URL. With a leaked gateway from an earlier session holding the port, the restart became a no-op: the freshly spawned gateway could not bind, stayed up serving only its metrics port, and every request kept going to the old process with audio off - a 404 from TextToSpeech and no way to tell why. Reuse is now decided by reuse_running_gateway: a plain start still adopts a gateway the desktop does not own, which is how an externally run one is supported, but a force or restart says so instead of pretending to have restarted.
Saving API keys restarts the gateway so the keys reach its env, but the only caller swallowed the failure into console.error, so a restart that could not happen looked like it had.
…ts wav

Dragging the right edge of a voice clip outwards pulled it back to where the speech ends, and its left edge would not move outwards at all. trimClip clamps a clip's tail to its source length, which is right for a music or video file but not for a spoken clip: the wav is synthesized to fit a slot and is routinely shorter than it, so the clamp fired on the first pixel of the drag. Spoken clips are now exempt from the source-length clamp on both edges, and a head trim can no longer produce a negative offset.
Clips only carried the track voice, so a lane of speech gave no way to see which sample each clip was cloned from or to change one without the agent asking. A spoken clip now keeps its own voice_sample, wears a stripe in that sample's colour, and the clip editor names it in a dropdown next to Redo voice - picking another drafts the clip and the redo prompt names it instead of asking. The picker is shared with the lane header, whose blank option listed the current sample twice.
@edenreich
edenreich merged commit 3c9b109 into main Sep 18, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-279 branch September 18, 2026 23:52
@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 0.44.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Captions track: styled, editable captions generated from the transcript

1 participant