Skip to content

🎥 Make videos programmatically with React

delete large-audio-mixing directory even if erroring out

Jonny Burger8b87d944c040
diff --git a/packages/renderer/src/merge-audio-track.ts b/packages/renderer/src/merge-audio-track.ts
index c542fc2ed8..07daea854c 100644
--- a/packages/renderer/src/merge-audio-track.ts
+++ b/packages/renderer/src/merge-audio-track.ts
@@ -54,31 +54,33 @@ const mergeAudioTrackUnlimited = async ({
const chunked = chunk(files, 10);
const tempPath = tmpDir('remotion-large-audio-mixing');
- const chunkNames = await Promise.all(
- chunked.map(async (chunkFiles, i) => {
- const chunkOutname = path.join(tempPath, `chunk-${i}.wav`);
- await mergeAudioTrack({
- ffmpegExecutable,
- files: chunkFiles,
- numberOfSeconds,
- outName: chunkOutname,
- downloadMap,
- remotionRoot,
- });
- return chunkOutname;
- })
- );
+ try {
+ const chunkNames = await Promise.all(
+ chunked.map(async (chunkFiles, i) => {
+ const chunkOutname = path.join(tempPath, `chunk-${i}.wav`);
+ await mergeAudioTrack({
+ ffmpegExecutable,
+ files: chunkFiles,
+ numberOfSeconds,
+ outName: chunkOutname,
+ downloadMap,
+ remotionRoot,
+ });
+ return chunkOutname;
+ })
+ );
- await mergeAudioTrack({
- ffmpegExecutable,
- files: chunkNames,
- numberOfSeconds,
- outName,
- downloadMap,
- remotionRoot,
- });
- await deleteDirectory(tempPath);
- return;
+ await mergeAudioTrack({
+ ffmpegExecutable,
+ files: chunkNames,
+ numberOfSeconds,
+ outName,
+ downloadMap,
+ remotionRoot,
+ });
+ } finally {
+ await deleteDirectory(tempPath);
+ }
}
const {complexFilterFlag: mergeFilter, cleanup} =