Skip to content

🎥 Make videos programmatically with React

`@remotion/renderer`: Run audio-only Fast Start away from the output path

Ahadi235e2cbf2582
diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.ts
index c04e76450e..7ddda98b51 100644
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@ -355,12 +355,18 @@ const innerStitchFramesToVideo = async (
);
}
- const audioOnlyDestination = outputLocation ?? (tempFile as string);
+ let audioOnlyFile = audio;
if (getMp4BrandForExtension(outputExtension)) {
+ // Mux away from the public output path: Fast Start reopens the file
+ // for a second pass, which Windows file observers can lock.
+ audioOnlyFile = path.join(
+ assetsInfo.downloadMap.stitchFrames,
+ `audio-only.${outputExtension}`,
+ );
await muxVideoAndAudio({
videoOutput: null,
audioOutput: audio,
- output: path.resolve(remotionRoot, audioOnlyDestination),
+ output: audioOnlyFile,
indent,
logLevel,
onProgress: () => undefined,
@@ -372,10 +378,9 @@ const innerStitchFramesToVideo = async (
audioCodec: resolvedAudioCodec,
sampleRate,
});
- } else {
- cpSync(audio, audioOnlyDestination);
}
+ cpSync(audioOnlyFile, outputLocation ?? (tempFile as string));
onProgress?.(Math.round(assetsInfo.chunkLengthInSeconds * fps));
deleteDirectory(path.dirname(audio));