Skip to content

🎥 Make videos programmatically with React

Merge branch 'main' into seamless-aac-stitching

Jonny Burgerf7b253de8758
diff --cc packages/lambda/src/functions/helpers/concat-videos.ts
index 6bed487f21,c111c76969..a62c6a625e
--- a/packages/lambda/src/functions/helpers/concat-videos.ts
+++ b/packages/lambda/src/functions/helpers/concat-videos.ts
@@@ -184,7 -190,7 +190,8 @@@ export const concatVideosS3 = async (
audioCodec,
audioBitrate,
logLevel,
+ framesPerLambda,
+ binariesDirectory,
}: {
onProgress: (frames: number) => void;
numberOfFrames: number;
@@@ -196,7 -202,7 +203,8 @@@
audioCodec: AudioCodec | null;
audioBitrate: string | null;
logLevel: LogLevel;
+ framesPerLambda: number;
+ binariesDirectory: string | null;
}) => {
const outfile = join(
RenderInternals.tmpDir(REMOTION_CONCATED_TOKEN),
@@@ -220,7 -224,7 +228,8 @@@
audioBitrate,
indent: false,
logLevel,
+ chunkDurationInSeconds,
+ binariesDirectory,
});
combine.end();
diff --cc packages/lambda/src/functions/helpers/merge-chunks.ts
index 2a0945008d,e33a1b4bc6..97e5455c0f
--- a/packages/lambda/src/functions/helpers/merge-chunks.ts
+++ b/packages/lambda/src/functions/helpers/merge-chunks.ts
@@@ -62,7 -61,7 +62,8 @@@ export const mergeChunksAndFinishRende
onAllChunks: OnAllChunksAvailable;
audioBitrate: string | null;
logLevel: LogLevel;
+ framesPerLambda: number;
+ binariesDirectory: string | null;
}): Promise<PostRenderData> => {
let lastProgressUploaded = 0;
@@@ -163,7 -166,7 +169,8 @@@
audioCodec: options.audioCodec,
audioBitrate: options.audioBitrate,
logLevel: options.logLevel,
+ framesPerLambda: options.framesPerLambda,
+ binariesDirectory: options.binariesDirectory,
});
const encodingStop = Date.now();
diff --cc packages/lambda/src/functions/launch.ts
index c84a7f2b96,5481eabc76..87ef24a9bd
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@@ -400,7 -399,7 +400,8 @@@ const innerLaunchHandler = async (
onAllChunks: onAllChunksAvailable,
audioBitrate: params.audioBitrate,
logLevel: params.logLevel,
+ framesPerLambda,
+ binariesDirectory: null,
});
return postRenderData;
diff --cc packages/lambda/src/functions/merge.ts
index f9c87656e6,107c159ec6..2699b3f8d8
--- a/packages/lambda/src/functions/merge.ts
+++ b/packages/lambda/src/functions/merge.ts
@@@ -72,7 -79,7 +79,8 @@@ export const mergeHandler = async
},
audioBitrate: renderMetadata.audioBitrate,
logLevel: params.logLevel,
+ framesPerLambda: params.framesPerLambda,
+ binariesDirectory: null,
});
return {type: 'success' as const, postRenderData};
diff --cc packages/renderer/src/combine-videos.ts
index 19d714b014,0b09740a14..4639584f87
--- a/packages/renderer/src/combine-videos.ts
+++ b/packages/renderer/src/combine-videos.ts
@@@ -25,7 -30,7 +25,8 @@@ type Options =
audioBitrate: string | null;
indent: boolean;
logLevel: LogLevel;
+ chunkDurationInSeconds: number;
+ binariesDirectory: string | null;
};
export const combineVideos = async (options: Options) => {
@@@ -42,10 -47,12 +43,11 @@@
audioBitrate,
indent,
logLevel,
+ chunkDurationInSeconds,
+ binariesDirectory,
} = options;
- const fileList = files.map((p) => `file '${p}'`).join('\n');
- const fileListTxt = join(filelistDir, 'files.txt');
- writeFileSync(fileListTxt, fileList);
+ // TODO: onProgress is now reused across 3 functions
const resolvedAudioCodec =
audioCodec ?? getDefaultAudioCodec({codec, preferLossless: false});
diff --cc packages/renderer/src/merge-audio-track.ts
index 14827d16b2,7df25d8dae..a7c28b66f1
--- a/packages/renderer/src/merge-audio-track.ts
+++ b/packages/renderer/src/merge-audio-track.ts
@@@ -20,7 -20,7 +20,8 @@@ type Options =
remotionRoot: string;
indent: boolean;
logLevel: LogLevel;
+ forceLossless: boolean;
+ binariesDirectory: string | null;
};
const mergeAudioTrackUnlimited = async ({
@@@ -31,7 -31,7 +32,8 @@@
remotionRoot,
indent,
logLevel,
+ forceLossless,
+ binariesDirectory,
}: Options): Promise<void> => {
if (files.length === 0) {
await createSilentAudio({
@@@ -62,7 -63,7 +65,8 @@@
remotionRoot,
indent,
logLevel,
+ forceLossless: true,
+ binariesDirectory,
});
return chunkOutname;
}),
@@@ -82,7 -83,7 +86,8 @@@
remotionRoot,
indent,
logLevel,
+ forceLossless: false,
+ binariesDirectory,
});
return;
} finally {
diff --cc packages/renderer/src/options/index.tsx
index 07e06b266b,11eb746060..702a3004f3
--- a/packages/renderer/src/options/index.tsx
+++ b/packages/renderer/src/options/index.tsx
@@@ -10,16 -11,21 +11,22 @@@ import {encodingMaxRateOption} from './
import {enforceAudioOption} from './enforce-audio';
import {folderExpiryOption} from './folder-expiry';
import {glOption} from './gl';
+ import {headlessOption} from './headless';
import {jpegQualityOption} from './jpeg-quality';
- import {muteOption} from './mute';
+ import {logLevelOption} from './log-level';
+ import {mutedOption} from './mute';
import {numberOfGifLoopsOption} from './number-of-gif-loops';
- import {offthreadVideoCacheSizeInBytes} from './offthreadvideo-cache-size';
+ import {offthreadVideoCacheSizeInBytesOption} from './offthreadvideo-cache-size';
+ import type {AnyRemotionOption} from './option';
+ import {overwriteOption} from './overwrite';
+import {preferLossless} from './prefer-lossless';
import {reproOption} from './repro';
import {scaleOption} from './scale';
- import {videoBitrate} from './video-bitrate';
+ import {delayRenderTimeoutInMillisecondsOption} from './timeout';
+ import {videoBitrateOption} from './video-bitrate';
import {videoCodecOption} from './video-codec';
import {webhookCustomDataOption} from './webhook-custom-data';
+ import {x264Option} from './x264-preset';
export const allOptions = {
scaleOption,
@@@ -43,7 -49,12 +50,13 @@@
beepOnFinishOption,
numberOfGifLoopsOption,
reproOption,
+ preferLossless,
+ x264Option,
+ logLevelOption,
+ delayRenderTimeoutInMillisecondsOption,
+ headlessOption,
+ overwriteOption,
+ binariesDirectoryOption,
};
export type AvailableOptions = keyof typeof allOptions;
diff --cc packages/renderer/src/options/options-map.ts
index 2f608298a4,ee0f57f452..3389afbecc
--- a/packages/renderer/src/options/options-map.ts
+++ b/packages/renderer/src/options/options-map.ts
@@@ -1,46 -1,116 +1,119 @@@
+ import {audioBitrateOption} from './audio-bitrate';
+ import {binariesDirectoryOption} from './binaries-directory';
+ import {colorSpaceOption} from './color-space';
+ import {crfOption} from './crf';
+ import {deleteAfterOption} from './delete-after';
+ import {encodingBufferSizeOption} from './encoding-buffer-size';
+ import {encodingMaxRateOption} from './encoding-max-rate';
+ import {enforceAudioOption} from './enforce-audio';
+ import {jpegQualityOption} from './jpeg-quality';
+ import {logLevelOption} from './log-level';
+ import {mutedOption} from './mute';
import {numberOfGifLoopsOption} from './number-of-gif-loops';
- import {offthreadVideoCacheSizeInBytes} from './offthreadvideo-cache-size';
+ import {offthreadVideoCacheSizeInBytesOption} from './offthreadvideo-cache-size';
+import {preferLossless} from './prefer-lossless';
import {reproOption} from './repro';
- import {videoBitrate} from './video-bitrate';
+ import {scaleOption} from './scale';
+ import {delayRenderTimeoutInMillisecondsOption} from './timeout';
+ import {videoBitrateOption} from './video-bitrate';
+ import {videoCodecOption} from './video-codec';
+ import {x264Option} from './x264-preset';
export const optionsMap = {
renderMedia: {
- offthreadVideoCacheSizeInBytes,
- videoBitrate,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
+ videoBitrate: videoBitrateOption,
numberOfGifLoops: numberOfGifLoopsOption,
repro: reproOption,
+ x264Preset: x264Option,
+ audioBitrate: audioBitrateOption,
+ colorSpace: colorSpaceOption,
+ codec: videoCodecOption,
+ jpegQuality: jpegQualityOption,
+ encodingMaxRate: encodingMaxRateOption,
+ encodingBufferSize: encodingBufferSizeOption,
+ muted: mutedOption,
+ logLevel: logLevelOption,
+ timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
+ binariesDirectory: binariesDirectoryOption,
},
renderStill: {
- offthreadVideoCacheSizeInBytes,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
+ jpegQuality: jpegQualityOption,
+ logLevel: logLevelOption,
+ timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
+ binariesDirectory: binariesDirectoryOption,
},
getCompositions: {
- offthreadVideoCacheSizeInBytes,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
+ logLevel: logLevelOption,
+ timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
+ binariesDirectory: binariesDirectoryOption,
},
selectComposition: {
- offthreadVideoCacheSizeInBytes,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
+ logLevel: logLevelOption,
+ timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
+ binariesDirectory: binariesDirectoryOption,
},
renderFrames: {
- offthreadVideoCacheSizeInBytes,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
+ jpegQuality: jpegQualityOption,
+ logLevel: logLevelOption,
+ timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
+ binariesDirectory: binariesDirectoryOption,
},
renderMediaOnLambda: {
- offthreadVideoCacheSizeInBytes,
- videoBitrate,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
+ videoBitrate: videoBitrateOption,
numberOfGifLoops: numberOfGifLoopsOption,
+ preferLossless,
+ audioBitrate: audioBitrateOption,
+ deleteAfter: deleteAfterOption,
+ x264Preset: x264Option,
+ encodingMaxRate: encodingMaxRateOption,
+ encodingBufferSize: encodingBufferSizeOption,
+ colorSpace: colorSpaceOption,
+ muted: mutedOption,
+ logLevel: logLevelOption,
+ timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
},
renderStillOnLambda: {
- offthreadVideoCacheSizeInBytes,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
+ jpegQuality: jpegQualityOption,
+ logLevel: logLevelOption,
+ deleteAfter: deleteAfterOption,
+ scale: scaleOption,
+ timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
},
getCompositionsOnLambda: {
- offthreadVideoCacheSizeInBytes,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
+ logLevel: logLevelOption,
+ timeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
},
renderMediaOnCloudRun: {
- offthreadVideoCacheSizeInBytes,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
numberOfGifLoops: numberOfGifLoopsOption,
+ preferLossless,
+ colorSpace: colorSpaceOption,
+ audioBitrate: audioBitrateOption,
+ videoBitrate: videoBitrateOption,
+ x264Preset: x264Option,
+ encodingMaxRate: encodingMaxRateOption,
+ encodingBufferSize: encodingBufferSizeOption,
+ muted: mutedOption,
+ logLevel: logLevelOption,
+ delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
+ enforceAudioTrack: enforceAudioOption,
+ scale: scaleOption,
+ crf: crfOption,
+ jpegQuality: jpegQualityOption,
},
renderStillOnCloudRun: {
- offthreadVideoCacheSizeInBytes,
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytesOption,
+ logLevel: logLevelOption,
+ scale: scaleOption,
+ jpegQuality: jpegQualityOption,
+ delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption,
},
} as const;
diff --cc packages/renderer/src/stitch-frames-to-video.ts
index a5ca5024d6,5fb300609b..12be7b7ca4
--- a/packages/renderer/src/stitch-frames-to-video.ts
+++ b/packages/renderer/src/stitch-frames-to-video.ts
@@@ -181,7 -190,7 +186,8 @@@ const getAssetsData = async (
remotionRoot,
indent,
logLevel,
+ forceLossless: false,
+ binariesDirectory,
});
onProgress(1);