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

fix: stop the upscale finalize mux from trimming the video to a shorter audio track (#6514)

[._.]/ Adam Eivy19843c8022a2
diff --git a/server/services/videoGen/upscaleFfmpeg.js b/server/services/videoGen/upscaleFfmpeg.js
index 262bd51666..85d5d629f9 100644
--- a/server/services/videoGen/upscaleFfmpeg.js
+++ b/server/services/videoGen/upscaleFfmpeg.js
@@ -101,8 +101,14 @@ export const finalizeUpscaleOutput = async (renderedPath, outPath, {
...H264_ENCODE_ARGS,
...BT709_CONTAINER_ARGS,
'-c:a', 'copy',
+ // The video is bounded to the SOURCE's frame count here, and nothing
+ // else. `-shortest` must not be added: an AAC track routinely runs a few
+ // milliseconds short of its video (priming/padding), and `-shortest`
+ // then cuts the video to the audio's length — the #6514 matrix measured
+ // a 25-frame source come back with 23 frames, and a 23-frame one with
+ // 19. The source's own container already pairs this video length with
+ // this audio length, so the deliverable simply keeps both.
'-frames:v', String(Math.round(frameCount)),
- '-shortest',
'-movflags', '+faststart',
'-y', outPath,
],
diff --git a/server/services/videoGen/upscaleFfmpeg.test.js b/server/services/videoGen/upscaleFfmpeg.test.js
index cb29457893..aaae109b72 100644
--- a/server/services/videoGen/upscaleFfmpeg.test.js
+++ b/server/services/videoGen/upscaleFfmpeg.test.js
@@ -60,6 +60,15 @@ describe('finalizeUpscaleOutput', () => {
expect(argFor('-frames:v')).toBe('121');
});
+ // The #6514 matrix measured a 25-frame source come back with 23 frames: an
+ // AAC track runs a few ms short of its video, and `-shortest` cut the video
+ // to the audio's length. The frame bound above is the only trim; the
+ // deliverable keeps the source's own video/audio lengths.
+ it('never lets the audio track shorten the video', async () => {
+ await finalize();
+ expect(ffmpeg.runs.at(-1).args).not.toContain('-shortest');
+ });
+
it('maps the source audio OPTIONALLY, so a silent source is a silent output rather than a failure', async () => {
await finalize();
const args = ffmpeg.runs.at(-1).args;