Skip to content

🎥 Make videos programmatically with React

unnecessary refactor

Jonny Burger3e10590a1c30
diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.ts
index 4158551e15..9d283a0804 100644
--- a/packages/lambda/src/functions/renderer.ts
+++ b/packages/lambda/src/functions/renderer.ts
@@ -147,11 +147,11 @@ const renderHandler = async (
const endRendered = Date.now();
console.info('Adding silent audio, chunk', params.chunk);
- await RenderInternals.addSilentAudioIfNecessary(
+ await RenderInternals.addSilentAudioIfNecessary({
outputLocation,
- params.frameRange[1] - params.frameRange[0] + 1,
- params.fps
- );
+ durationInFrames: params.frameRange[1] - params.frameRange[0] + 1,
+ fps: params.fps,
+ });
const condensedTimingData: ChunkTimingData = {
...chunkTimingData,
diff --git a/packages/renderer/src/add-silent-audio-if-necessary.ts b/packages/renderer/src/add-silent-audio-if-necessary.ts
index 0fc2d7177e..7aa04f191e 100644
--- a/packages/renderer/src/add-silent-audio-if-necessary.ts
+++ b/packages/renderer/src/add-silent-audio-if-necessary.ts
@@ -3,17 +3,21 @@ import {renameSync, unlinkSync} from 'fs';
import {getAudioChannels} from './assets/get-audio-channels';
import {DEFAULT_SAMPLE_RATE} from './sample-rate';
-export const addSilentAudioIfNecessary = async (
- videoFile: string,
- durationInFrames: number,
- fps: number
-): Promise<void> => {
- const audioChannels = await getAudioChannels(videoFile);
+export const addSilentAudioIfNecessary = async ({
+ durationInFrames,
+ fps,
+ outputLocation,
+}: {
+ outputLocation: string;
+ durationInFrames: number;
+ fps: number;
+}): Promise<void> => {
+ const audioChannels = await getAudioChannels(outputLocation);
if (audioChannels > 0) {
return;
}
- const out = videoFile + '-n';
+ const out = outputLocation + '-n';
await execa('ffmpeg', [
'-f',
@@ -21,7 +25,7 @@ export const addSilentAudioIfNecessary = async (
'-i',
'anullsrc',
'-i',
- videoFile,
+ outputLocation,
'-map',
'0:a:0',
'-map',
@@ -39,6 +43,6 @@ export const addSilentAudioIfNecessary = async (
'matroska',
out,
]);
- unlinkSync(videoFile);
- renameSync(out, videoFile);
+ unlinkSync(outputLocation);
+ renameSync(out, outputLocation);
};