Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat(video): mute unwanted shot audio without rerendering clips

[._.]/ Adam Eivy70fe5408fe3d
diff --git a/client/src/components/creative-director/VideoShotEditor.jsx b/client/src/components/creative-director/VideoShotEditor.jsx
index 5a72acba6f..3ba51e524b 100644
--- a/client/src/components/creative-director/VideoShotEditor.jsx
+++ b/client/src/components/creative-director/VideoShotEditor.jsx
@@ -7,15 +7,16 @@ export default function VideoShotEditor({ project, scene, onChange }) {
const [prompt, setPrompt] = useState(scene.prompt);
const [sourceImageFile, setSourceImageFile] = useState(scene.sourceImageFile || null);
const [continuation, setContinuation] = useState(Boolean(scene.useContinuationFromPrior));
+ const [muteAudio, setMuteAudio] = useState(Boolean(scene.muteAudio));
const [pickerOpen, setPickerOpen] = useState(false);
const [saving, setSaving] = useState(false);
const active = ['planning', 'rendering', 'stitching'].includes(project.status);
- const dirty = prompt !== scene.prompt || sourceImageFile !== (scene.sourceImageFile || null) || continuation !== Boolean(scene.useContinuationFromPrior);
+ const dirty = muteAudio !== Boolean(scene.muteAudio) || prompt !== scene.prompt || sourceImageFile !== (scene.sourceImageFile || null) || continuation !== Boolean(scene.useContinuationFromPrior);
const save = async () => {
if (saving || active || !dirty || !prompt.trim()) return;
setSaving(true);
const saved = await updateCreativeDirectorScene(project.id, scene.sceneId, {
- prompt, sourceImageFile, useContinuationFromPrior: continuation, expectedWorkRevision: scene.workRevision || 0,
+ prompt, sourceImageFile, muteAudio, useContinuationFromPrior: continuation, expectedWorkRevision: scene.workRevision || 0,
}, { silent: true }).catch(error => { toast.error(error.message || 'Could not save shot'); return null; });
setSaving(false);
if (saved) { toast.success('Shot saved. Review the updated production before resuming.'); onChange?.(); }
@@ -31,6 +32,8 @@ export default function VideoShotEditor({ project, scene, onChange }) {
</div>
<label htmlFor="video-shot-continuation" className="flex items-center gap-2 text-sm"><input id="video-shot-continuation" type="checkbox" checked={continuation} disabled={active || saving || scene.order === 0} onChange={event => setContinuation(event.target.checked)} />Continue from the previous shot's last frame</label>
{continuation && <p className="text-xs text-port-text-muted">Continuation uses the previous clip instead of the selected reference frame.</p>}
+ <label htmlFor="video-shot-mute-audio" className="flex items-center gap-2 text-sm"><input id="video-shot-mute-audio" type="checkbox" checked={muteAudio} disabled={active || saving} onChange={event => setMuteAudio(event.target.checked)} />Mute generated audio in the final cut</label>
+ <p className="text-xs text-port-text-muted">Muting removes all sound from this shot. Changing only this control preserves its rendered picture and requires a fresh review.</p>
<p className="text-xs text-port-text-muted">{active ? 'Pause production before editing this shot.' : 'Saving pauses production and requires a fresh review. It makes no provider calls.'}</p>
<button className="rounded bg-port-accent px-3 py-2 text-white disabled:opacity-40" disabled={active || saving || !dirty || !prompt.trim()} onClick={save}>{saving ? 'Saving…' : 'Save shot'}</button>
<GalleryImagePicker open={pickerOpen} onClose={() => setPickerOpen(false)} onSelect={item => { setSourceImageFile(item.filename); setContinuation(false); }} allowUpload />
diff --git a/client/src/components/creative-director/VideoShotEditor.test.jsx b/client/src/components/creative-director/VideoShotEditor.test.jsx
index db2b11f53b..e304f2d5b9 100644
--- a/client/src/components/creative-director/VideoShotEditor.test.jsx
+++ b/client/src/components/creative-director/VideoShotEditor.test.jsx
@@ -14,7 +14,7 @@ it('keeps unsaved reference edits after a failed save and submits the displayed
render(<VideoShotEditor project={{ id: 'cd-example', status: 'paused' }} scene={{ sceneId: 'shot-2', order: 1, prompt: 'A garden path', workRevision: 3, useContinuationFromPrior: true }} onChange={onChange} />);
await user.click(screen.getByRole('button', { name: 'Choose reference frame' }));
await user.click(screen.getByRole('button', { name: 'Example reference' }));
- expect(screen.getByRole('checkbox')).not.toBeChecked();
+ expect(screen.getByRole('checkbox', { name: /Continue from/ })).not.toBeChecked();
updateCreativeDirectorScene.mockRejectedValueOnce(new Error('Unavailable')).mockResolvedValueOnce({});
await user.click(screen.getByRole('button', { name: 'Save shot' }));
await waitFor(() => expect(toast.error).toHaveBeenCalledWith('Unavailable'));
@@ -22,5 +22,15 @@ it('keeps unsaved reference edits after a failed save and submits the displayed
expect(screen.getByRole('img', { name: 'Shot reference frame' })).toHaveAttribute('src', '/data/images/example-frame.png');
await user.click(screen.getByRole('button', { name: 'Save shot' }));
await waitFor(() => expect(onChange).toHaveBeenCalledOnce());
- expect(updateCreativeDirectorScene).toHaveBeenLastCalledWith('cd-example', 'shot-2', { prompt: 'A garden path', sourceImageFile: 'example-frame.png', useContinuationFromPrior: false, expectedWorkRevision: 3 }, { silent: true });
+ expect(updateCreativeDirectorScene).toHaveBeenLastCalledWith('cd-example', 'shot-2', { prompt: 'A garden path', sourceImageFile: 'example-frame.png', muteAudio: false, useContinuationFromPrior: false, expectedWorkRevision: 3 }, { silent: true });
+});
+
+
+it('saves a mute-only repair with the displayed shot revision', async () => {
+ const user = userEvent.setup();
+ updateCreativeDirectorScene.mockClear().mockResolvedValue({});
+ render(<VideoShotEditor project={{ id: 'cd-example', status: 'paused' }} scene={{ sceneId: 'shot-3', order: 2, prompt: 'An empty garden', workRevision: 4 }} />);
+ await user.click(screen.getByRole('checkbox', { name: 'Mute generated audio in the final cut' }));
+ await user.click(screen.getByRole('button', { name: 'Save shot' }));
+ expect(updateCreativeDirectorScene).toHaveBeenCalledWith('cd-example', 'shot-3', expect.objectContaining({ muteAudio: true, expectedWorkRevision: 4 }), { silent: true });
});
diff --git a/server/lib/creativeDirectorValidation.js b/server/lib/creativeDirectorValidation.js
index 4d48c0788c..2d5dd41ff1 100644
--- a/server/lib/creativeDirectorValidation.js
+++ b/server/lib/creativeDirectorValidation.js
@@ -296,6 +296,7 @@ export const creativeDirectorProjectQuerySchema = z.object({
// One scene in the treatment, written by the agent on the treatment task.
export const creativeDirectorSceneSchema = z.object({
+ muteAudio: z.boolean().optional(),
sceneId: z.string().min(1).max(64),
order: z.number().int().min(0),
intent: z.string().min(1).max(1000),
@@ -341,6 +342,7 @@ export const creativeDirectorTreatmentSchema = z.object({
// Used by the agent when finishing a scene render.
export const creativeDirectorSceneUpdateSchema = z.object({
+ muteAudio: z.boolean().optional(),
expectedWorkRevision: z.number().int().min(0).optional(),
sourceImageFile: safeBasename.nullable().optional(),
useContinuationFromPrior: z.boolean().optional(),
diff --git a/server/lib/creativeDirectorVideoReview.js b/server/lib/creativeDirectorVideoReview.js
index 2a3d89c05a..e253f200a4 100644
--- a/server/lib/creativeDirectorVideoReview.js
+++ b/server/lib/creativeDirectorVideoReview.js
@@ -9,8 +9,11 @@ const fingerprint = value => canonicalSnapshotChecksum(value);
/** Creative inputs only: runtime status/evaluation changes cannot stale script approval. */
export function videoSceneInputs(scene) {
- return Object.fromEntries(['sceneId', 'order', 'durationSeconds', 'intent', 'prompt', 'negativePrompt',
+ const inputs = Object.fromEntries(['sceneId', 'order', 'durationSeconds', 'intent', 'prompt', 'negativePrompt',
'sourceImageFile', 'imageStrength', 'useContinuationFromPrior', 'cast'].map(key => [key, scene?.[key] ?? null]));
+ // Leave existing approval fingerprints unchanged until a shot is muted.
+ if (scene?.muteAudio) inputs.muteAudio = true;
+ return inputs;
}
export function assertVideoOwner(project, instanceId) {
diff --git a/server/services/creativeDirector/projectsLogic.js b/server/services/creativeDirector/projectsLogic.js
index f20e5ce0be..5109bdc3a8 100644
--- a/server/services/creativeDirector/projectsLogic.js
+++ b/server/services/creativeDirector/projectsLogic.js
@@ -598,6 +598,11 @@ export function applySceneUpdate(project, sceneId, patch) {
const treatment = { ...project.treatment, scenes };
const creativeEdit = project.workspace === 'video' && treatment.artifact
&& ['prompt', 'imageStrength', 'sourceImageFile', 'useContinuationFromPrior'].some((key) => key in patch && patch[key] !== previousScene[key]);
+ const audioEdit = project.workspace === 'video' && 'muteAudio' in patch && Boolean(patch.muteAudio) !== Boolean(previousScene.muteAudio);
+ if (audioEdit && ['planning', 'rendering', 'stitching'].includes(project.status)) {
+ throw new ServerError('Pause production before changing shot audio.', { status: 409, code: 'VIDEO_ACTIVE' });
+ }
+ if (audioEdit && !creativeEdit) updated.workRevision = (previousScene.workRevision || 0) + 1;
if (creativeEdit) {
validateVideoShot(project, updated, sceneId === [...scenes].sort((a, b) => a.order - b.order)[0].sceneId);
updated.workRevision = (previousScene.workRevision || 0) + 1;
@@ -623,7 +628,7 @@ export function applySceneUpdate(project, sceneId, patch) {
...project,
treatment,
...(creativeEdit && project.plan?.steps ? { plan: retireVideoPlan(project.plan) } : {}),
- ...(creativeEdit ? { status: 'paused', videoWorkRevision: (project.videoWorkRevision || 0) + 1, videoCutHistory: retainVideoCuts(project), videoRoughCut: null, videoFinalCut: null, finalVideoId: null } : {}),
+ ...((creativeEdit || audioEdit) ? { status: 'paused', videoWorkRevision: (project.videoWorkRevision || 0) + 1, videoCutHistory: retainVideoCuts(project), videoRoughCut: null, videoFinalCut: null, finalVideoId: null } : {}),
updatedAt: new Date().toISOString(),
};
return { project: next, updated };
diff --git a/server/services/creativeDirector/videoAssembly.js b/server/services/creativeDirector/videoAssembly.js
index b4c775271f..9cc3b82a3e 100644
--- a/server/services/creativeDirector/videoAssembly.js
+++ b/server/services/creativeDirector/videoAssembly.js
@@ -33,7 +33,7 @@ async function prepareClips(project, history) {
})
: [...(project.treatment?.scenes || [])].sort((a, b) => a.order - b.order).map(scene => {
if (scene.status !== 'accepted' || !scene.renderedJobId) throw fail('Every shot must be accepted before assembly. Partial clips remain available in Artifacts.');
- return { clipId: scene.renderedJobId, outSec: scene.durationSeconds };
+ return { clipId: scene.renderedJobId, outSec: scene.durationSeconds, muteAudio: Boolean(scene.muteAudio) };
});
if (!requested.length) throw fail('No completed clips are available to assemble.');
const segments = [];
@@ -46,12 +46,12 @@ async function prepareClips(project, history) {
if (!playable.ok) throw fail(`A required clip is not playable: ${playable.reason}. Revise or render that shot again.`);
const [duration, stream, audio] = await Promise.all([probeVideoDuration(path), probeVideoStreamInfo(path), hasAudioStream(path)]);
if (!(duration > 0 && stream.fps > 0)) throw fail('A source clip duration could not be verified. Check ffprobe and the source file.');
- if (project.videoExecution.choices.audio.mode === 'native' && !audio) throw fail('A source clip has no native audio. Select silent or a soundtrack before resuming.');
+ if (project.videoExecution.choices.audio.mode === 'native' && !clip.muteAudio && !audio) throw fail('A source clip has no native audio. Select silent or a soundtrack before resuming.');
if (!(clip.outSec > 0) || clip.outSec > duration + 1 / stream.fps + 1e-6) throw fail('A rendered clip is shorter than its planned shot. Revise the timing or render the shot again.');
if (remaining <= 0) throw fail('The planned shots exceed the exact target before the last shot. Revise their timing so every shot fits the final cut.');
const outSec = Math.min(clip.outSec, duration, remaining);
const fadeSec = project.videoDraft.transition === 'fade' ? Math.min(0.25, outSec / 2) : 0;
- segments.push({ type: 'clip', clipId: clip.clipId, inSec: 0, outSec, fadeInSec: fadeSec, fadeOutSec: fadeSec });
+ segments.push({ type: 'clip', clipId: clip.clipId, inSec: 0, outSec, fadeInSec: fadeSec, fadeOutSec: fadeSec, ...(clip.muteAudio ? { volume: 0 } : {}) });
remaining -= outSec;
}
if (!segments.length) throw fail('The requested cut has no playable duration.');
diff --git a/server/services/creativeDirector/videoAssembly.test.js b/server/services/creativeDirector/videoAssembly.test.js
index 2f06988a9c..89933e0707 100644
--- a/server/services/creativeDirector/videoAssembly.test.js
+++ b/server/services/creativeDirector/videoAssembly.test.js
@@ -123,3 +123,27 @@ it('rejects missing, corrupt, out-of-range and missing-audio finals even when hi
state.project.videoExecution.choices.audio.mode = 'native';
await expect(validateVideoCut(state.project, entry)).rejects.toThrow(/missing its requested audio/);
});
+
+
+it('mutes a selected shot in the real cut while retaining the next shot audio', async context => {
+ requireFfmpeg(context);
+ await exec(ffmpeg, ['-y', '-f', 'lavfi', '-i', 'color=c=green:s=64x64:r=24:d=3', '-f', 'lavfi', '-i', 'sine=frequency=440:duration=3', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-c:a', 'aac', '-shortest', join(state.root, 'videos', 'native.mp4')]);
+ state.history.forEach(row => { row.filename = 'native.mp4'; });
+ state.project.videoDraft.audio = { mode: 'native' };
+ state.project.videoDraft.transition = 'cut';
+ state.project.videoExecution.choices.audio = { mode: 'native' };
+ state.project.treatment.scenes[0].muteAudio = true;
+ state.project.videoExecution.inputRevision = videoConfigurationRevision(state.project);
+ await runVideoAssembly('example-video');
+ expect(state.project.failureReason).toBeNull();
+ expect(state.project.status).toBe('complete');
+ const output = join(state.root, 'videos', state.project.videoFinalCut.filename);
+ const rms = async start => {
+ const { stdout } = await exec(ffmpeg, ['-v', 'error', '-ss', String(start), '-i', output, '-t', '0.5', '-vn', '-ac', '1', '-ar', '8000', '-f', 'f32le', 'pipe:1'], { encoding: 'buffer' });
+ let square = 0;
+ for (let i = 0; i < stdout.length; i += 4) square += stdout.readFloatLE(i) ** 2;
+ return Math.sqrt(square / (stdout.length / 4));
+ };
+ expect(await rms(1)).toBeLessThan(0.0001);
+ expect(await rms(4)).toBeGreaterThan(0.01);
+}, 30000);
diff --git a/server/services/creativeDirector/videoReview.test.js b/server/services/creativeDirector/videoReview.test.js
index f5222ce655..e1b7ac406e 100644
--- a/server/services/creativeDirector/videoReview.test.js
+++ b/server/services/creativeDirector/videoReview.test.js
@@ -128,3 +128,20 @@ describe('Video review workflow', () => {
await expect(reviewVideo('example-video', await inputFor('script-shot-plan', 'approve'))).rejects.toMatchObject({ code: 'VIDEO_OWNER_REQUIRED' });
});
});
+
+
+it('preserves paid clips and continuation frames when only the cut audio changes, and invalidates review', async () => {
+ mocks.project.status = 'paused';
+ await reviewVideo('example-video', await inputFor('script-shot-plan', 'approve'));
+ mocks.project.status = 'paused';
+ const before = structuredClone(mocks.project.treatment.scenes);
+ mocks.project = applySceneUpdate(mocks.project, 'one', { muteAudio: true, expectedWorkRevision: 0 }).project;
+ expect(mocks.project.treatment.scenes.map(s => s.renderedJobId)).toEqual(before.map(s => s.renderedJobId));
+ expect(mocks.project.treatment.scenes.map(s => s.status)).toEqual(['accepted', 'accepted', 'accepted']);
+ expect(mocks.project.treatment.scenes.map(s => s.workRevision)).toEqual([1, 0, 0]);
+ expect(mocks.project.videoRoughCut).toBeNull();
+ expect(mocks.project.videoFinalCut).toBeNull();
+ expect(await videoReviewAllowsDispatch('example-video', ['script-shot-plan'])).toBe(false);
+ mocks.project.status = 'rendering';
+ expect(() => applySceneUpdate(mocks.project, 'one', { muteAudio: false, expectedWorkRevision: 1 })).toThrow('Pause production');
+});