Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(editor): smooth audio-track preview and stop audio becoming a clip
Benjamin Freemanc96afe853bb6
diff --git a/src/components/ai-edition/NewEditorShell.tsx b/src/components/ai-edition/NewEditorShell.tsxindex 791a08f1e..81b9ab7d7 100644--- a/src/components/ai-edition/NewEditorShell.tsx+++ b/src/components/ai-edition/NewEditorShell.tsx@@ -434,7 +434,16 @@ export function NewEditorShell() {const handleDropAsset = useCallback((assetId: string) =>enqueueTimelineWrite(() => {- const at = useProjectStore.getState().document?.timeline.clips.length ?? 0;+ const doc = useProjectStore.getState().document;+ // An audio asset has no video, so it must never become a clip (issue+ // #350) — it goes on the audio lane as a track. Adding it "to the+ // timeline" reuses its existing track if it already has one (importing+ // already placed one) so the same file can't stack up duplicate lanes.+ if (doc?.assets.find((a) => a.id === assetId)?.kind === "audio") {+ if (doc.audioTracks.some((t) => t.assetId === assetId)) return Promise.resolve();+ return tl.addAudioTrack(assetId).then(() => undefined);+ }+ const at = doc?.timeline.clips.length ?? 0;return tl.insertClipAt(assetId, at);}).catch((error) => {toast.error(te("mediaStage.couldNotAddAsset"), {diff --git a/src/components/ai-edition/VirtualPreview.tsx b/src/components/ai-edition/VirtualPreview.tsxindex b0d6d0685..eb9e83943 100644--- a/src/components/ai-edition/VirtualPreview.tsx+++ b/src/components/ai-edition/VirtualPreview.tsx@@ -533,7 +533,17 @@ export function VirtualPreview({const trackTarget = resolveTimelineAudioPlayback(virtualTimeSecRef.current, track);if (el.playbackRate !== v.playbackRate) el.playbackRate = v.playbackRate;el.volume = Math.min(1, audioGainScalar(track.gainDb) * globalGain);- if (Math.abs(el.currentTime - trackTarget.targetTimeSec) > 0.025) {+ // Only re-seek on a real discontinuity (a scrub, a trim jump, a first+ // play), NOT on the sub-frame drift of normal playback. The primary audio+ // can afford a 25 ms leash because it syncs to the <video>'s own+ // authoritative clock; an imported track syncs to `virtualTimeSec`, which is+ // DERIVED from that clock each frame and so is slightly noisy — at a 25 ms+ // leash it re-seeks most frames, and each seek briefly stalls the element:+ // the jitter. A started element already plays at the right rate from the+ // right offset, so it free-runs in sync; this wide leash just catches the+ // jumps. BGM/voiceover tolerates it; frame-tight sync is the video's job.+ const leashSec = !el.paused && trackTarget.shouldPlay ? 0.3 : 0.025;+ if (Math.abs(el.currentTime - trackTarget.targetTimeSec) > leashSec) {try {el.currentTime = trackTarget.targetTimeSec;} catch {