🎥 Make videos programmatically with React
hmm
Jonny Burger31b5e7a3de3e
diff --git a/packages/lambda/src/functions/helpers/merge-chunks.ts b/packages/lambda/src/functions/helpers/merge-chunks.tsindex 4ac21a46ea..d2a95efda1 100644--- a/packages/lambda/src/functions/helpers/merge-chunks.ts+++ b/packages/lambda/src/functions/helpers/merge-chunks.ts@@ -42,6 +42,7 @@ export type OnAllChunksAvailable = (options: {inputProps: SerializedInputProps;serializedResolvedProps: SerializedInputProps;framesPerLambda: number;+ compositionStart: number;}) => void;export const mergeChunksAndFinishRender = async (options: {@@ -68,6 +69,7 @@ export const mergeChunksAndFinishRender = async (options: {framesPerLambda: number;binariesDirectory: string | null;preferLossless: boolean;+ compositionStart: number;}): Promise<PostRenderData> => {let lastProgressUploaded = 0;@@ -166,6 +168,7 @@ export const mergeChunksAndFinishRender = async (options: {inputProps: options.inputProps,serializedResolvedProps: options.serializedResolvedProps,framesPerLambda: options.framesPerLambda,+ compositionStart: options.compositionStart,});const encodingStart = Date.now();const {outfile, cleanupChunksProm} = await concatVideosS3({diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex c69cafe148..54eae611a4 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -409,6 +409,7 @@ const innerLaunchHandler = async ({framesPerLambda,binariesDirectory: null,preferLossless: params.preferLossless,+ compositionStart: realFrameRange[0] / fps,});return postRenderData;@@ -418,6 +419,7 @@ type AllChunksAvailable = {inputProps: SerializedInputProps;serializedResolvedProps: SerializedInputProps;framesPerLambda: number;+ compositionStart: number;};export const launchHandler = async (@@ -465,6 +467,7 @@ export const launchHandler = async (logLevel: params.logLevel,framesPerLambda: allChunksAvailable.framesPerLambda,preferLossless: params.preferLossless,+ compositionStart: allChunksAvailable.compositionStart,},retries: 2,});@@ -603,11 +606,13 @@ export const launchHandler = async (inputProps,serializedResolvedProps,framesPerLambda,+ compositionStart,}) => {allChunksAvailable = {inputProps,serializedResolvedProps,framesPerLambda,+ compositionStart,};},});diff --git a/packages/lambda/src/functions/merge.ts b/packages/lambda/src/functions/merge.tsindex 5664997a4f..03b6064976 100644--- a/packages/lambda/src/functions/merge.ts+++ b/packages/lambda/src/functions/merge.ts@@ -86,6 +86,7 @@ export const mergeHandler = async (framesPerLambda: params.framesPerLambda,binariesDirectory: null,preferLossless: params.preferLossless,+ compositionStart: params.compositionStart,});return {type: 'success' as const, postRenderData};diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.tsindex 8cc364f403..3106bab178 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda/src/shared/constants.ts@@ -436,6 +436,7 @@ export type LambdaPayloads = {logLevel: LogLevel;framesPerLambda: number;preferLossless: boolean;+ compositionStart: number;};};diff --git a/packages/lambda/src/test/integration/renders/seamless-audio.test.ts b/packages/lambda/src/test/integration/renders/seamless-audio.test.tsindex cf95d03694..31ced0394f 100644--- a/packages/lambda/src/test/integration/renders/seamless-audio.test.ts+++ b/packages/lambda/src/test/integration/renders/seamless-audio.test.ts@@ -1,4 +1,5 @@import {RenderInternals} from '@remotion/renderer';+import {readFileSync} from 'fs';import path from 'path';import {afterAll, expect, test} from 'vitest';import {deleteRender} from '../../../api/delete-render';@@ -34,6 +35,9 @@ test('Should make seamless audio', async () => {logLevel: 'info',});+ const waveForm = readFileSync(wav);+ const buf = waveForm.subarray(100000, 100000 + 2000);+const files = await lambdaLs({bucketName: progress.outBucket as string,region: 'eu-central-1',@@ -59,4 +63,130 @@ test('Should make seamless audio', async () => {expect(expectFiles.length).toBe(0);await close();++ expect(buf).toEqual(+ Buffer.from([+ 179, 244, 204, 244, 204, 244, 21, 245, 21, 245, 143, 245, 143, 245, 55,+ 246, 55, 246, 9, 247, 9, 247, 2, 248, 2, 248, 30, 249, 30, 249, 88, 250,+ 88, 250, 172, 251, 172, 251, 18, 253, 18, 253, 133, 254, 133, 254, 255,+ 255, 255, 255, 120, 1, 120, 1, 235, 2, 235, 2, 81, 4, 81, 4, 165, 5, 165,+ 5, 223, 6, 223, 6, 252, 7, 252, 7, 246, 8, 246, 8, 200, 9, 200, 9, 111,+ 10, 111, 10, 233, 10, 233, 10, 50, 11, 50, 11, 75, 11, 75, 11, 51, 11, 51,+ 11, 233, 10, 233, 10, 112, 10, 112, 10, 200, 9, 200, 9, 246, 8, 246, 8,+ 253, 7, 253, 7, 224, 6, 224, 6, 166, 5, 166, 5, 83, 4, 83, 4, 237, 2, 237,+ 2, 121, 1, 121, 1, 0, 0, 0, 0, 134, 254, 134, 254, 19, 253, 19, 253, 173,+ 251, 173, 251, 90, 250, 90, 250, 30, 249, 30, 249, 2, 248, 2, 248, 9, 247,+ 9, 247, 54, 246, 54, 246, 142, 245, 142, 245, 20, 245, 20, 245, 203, 244,+ 203, 244, 178, 244, 178, 244, 202, 244, 202, 244, 20, 245, 20, 245, 141,+ 245, 141, 245, 53, 246, 53, 246, 7, 247, 7, 247, 1, 248, 1, 248, 29, 249,+ 29, 249, 88, 250, 88, 250, 172, 251, 172, 251, 17, 253, 17, 253, 132, 254,+ 132, 254, 254, 255, 254, 255, 120, 1, 120, 1, 235, 2, 235, 2, 82, 4, 82,+ 4, 165, 5, 165, 5, 224, 6, 224, 6, 253, 7, 253, 7, 247, 8, 247, 8, 201, 9,+ 201, 9, 112, 10, 112, 10, 234, 10, 234, 10, 52, 11, 52, 11, 76, 11, 76,+ 11, 52, 11, 52, 11, 234, 10, 234, 10, 113, 10, 113, 10, 202, 9, 202, 9,+ 247, 8, 247, 8, 254, 7, 254, 7, 225, 6, 225, 6, 166, 5, 166, 5, 83, 4, 83,+ 4, 237, 2, 237, 2, 122, 1, 122, 1, 0, 0, 0, 0, 134, 254, 134, 254, 19,+ 253, 19, 253, 172, 251, 172, 251, 89, 250, 89, 250, 30, 249, 30, 249, 1,+ 248, 1, 248, 7, 247, 7, 247, 52, 246, 52, 246, 141, 245, 141, 245, 20,+ 245, 20, 245, 201, 244, 201, 244, 177, 244, 177, 244, 201, 244, 201, 244,+ 19, 245, 19, 245, 141, 245, 141, 245, 52, 246, 52, 246, 6, 247, 6, 247, 0,+ 248, 0, 248, 28, 249, 28, 249, 87, 250, 87, 250, 171, 251, 171, 251, 18,+ 253, 18, 253, 134, 254, 134, 254, 255, 255, 255, 255, 120, 1, 120, 1, 236,+ 2, 236, 2, 82, 4, 82, 4, 166, 5, 166, 5, 224, 6, 224, 6, 253, 7, 253, 7,+ 247, 8, 247, 8, 201, 9, 201, 9, 113, 10, 113, 10, 235, 10, 235, 10, 53,+ 11, 53, 11, 78, 11, 78, 11, 54, 11, 54, 11, 236, 10, 236, 10, 113, 10,+ 113, 10, 202, 9, 202, 9, 248, 8, 248, 8, 253, 7, 253, 7, 225, 6, 225, 6,+ 167, 5, 167, 5, 83, 4, 83, 4, 236, 2, 236, 2, 121, 1, 121, 1, 255, 255,+ 255, 255, 134, 254, 134, 254, 18, 253, 18, 253, 171, 251, 171, 251, 87,+ 250, 87, 250, 29, 249, 29, 249, 0, 248, 0, 248, 7, 247, 7, 247, 53, 246,+ 53, 246, 142, 245, 142, 245, 20, 245, 20, 245, 202, 244, 202, 244, 177,+ 244, 177, 244, 202, 244, 202, 244, 19, 245, 19, 245, 141, 245, 141, 245,+ 53, 246, 53, 246, 7, 247, 7, 247, 1, 248, 1, 248, 29, 249, 29, 249, 88,+ 250, 88, 250, 172, 251, 172, 251, 18, 253, 18, 253, 134, 254, 134, 254,+ 255, 255, 255, 255, 122, 1, 122, 1, 237, 2, 237, 2, 83, 4, 83, 4, 167, 5,+ 167, 5, 226, 6, 226, 6, 255, 7, 255, 7, 248, 8, 248, 8, 202, 9, 202, 9,+ 114, 10, 114, 10, 236, 10, 236, 10, 53, 11, 53, 11, 77, 11, 77, 11, 52,+ 11, 52, 11, 234, 10, 234, 10, 112, 10, 112, 10, 200, 9, 200, 9, 246, 8,+ 246, 8, 252, 7, 252, 7, 223, 6, 223, 6, 165, 5, 165, 5, 81, 4, 81, 4, 234,+ 2, 234, 2, 120, 1, 120, 1, 254, 255, 254, 255, 132, 254, 132, 254, 17,+ 253, 17, 253, 171, 251, 171, 251, 87, 250, 87, 250, 28, 249, 28, 249, 0,+ 248, 0, 248, 6, 247, 6, 247, 52, 246, 52, 246, 141, 245, 141, 245, 19,+ 245, 19, 245, 201, 244, 201, 244, 177, 244, 177, 244, 203, 244, 203, 244,+ 21, 245, 21, 245, 142, 245, 142, 245, 54, 246, 54, 246, 9, 247, 9, 247, 2,+ 248, 2, 248, 32, 249, 32, 249, 90, 250, 90, 250, 173, 251, 173, 251, 20,+ 253, 20, 253, 135, 254, 135, 254, 0, 0, 0, 0, 122, 1, 122, 1, 237, 2, 237,+ 2, 84, 4, 84, 4, 167, 5, 167, 5, 226, 6, 226, 6, 254, 7, 254, 7, 248, 8,+ 248, 8, 202, 9, 202, 9, 113, 10, 113, 10, 234, 10, 234, 10, 51, 11, 51,+ 11, 76, 11, 76, 11, 51, 11, 51, 11, 233, 10, 233, 10, 112, 10, 112, 10,+ 199, 9, 199, 9, 245, 8, 245, 8, 252, 7, 252, 7, 222, 6, 222, 6, 164, 5,+ 164, 5, 81, 4, 81, 4, 234, 2, 234, 2, 119, 1, 119, 1, 254, 255, 254, 255,+ 131, 254, 131, 254, 16, 253, 16, 253, 171, 251, 171, 251, 87, 250, 87,+ 250, 29, 249, 29, 249, 0, 248, 0, 248, 7, 247, 7, 247, 53, 246, 53, 246,+ 141, 245, 141, 245, 20, 245, 20, 245, 202, 244, 202, 244, 179, 244, 179,+ 244, 204, 244, 204, 244, 21, 245, 21, 245, 143, 245, 143, 245, 55, 246,+ 55, 246, 9, 247, 9, 247, 3, 248, 3, 248, 32, 249, 32, 249, 91, 250, 91,+ 250, 174, 251, 174, 251, 20, 253, 20, 253, 136, 254, 136, 254, 2, 0, 2, 0,+ 123, 1, 123, 1, 238, 2, 238, 2, 84, 4, 84, 4, 167, 5, 167, 5, 225, 6, 225,+ 6, 253, 7, 253, 7, 247, 8, 247, 8, 201, 9, 201, 9, 112, 10, 112, 10, 233,+ 10, 233, 10, 50, 11, 50, 11, 75, 11, 75, 11, 50, 11, 50, 11, 232, 10, 232,+ 10, 111, 10, 111, 10, 200, 9, 200, 9, 245, 8, 245, 8, 252, 7, 252, 7, 223,+ 6, 223, 6, 165, 5, 165, 5, 81, 4, 81, 4, 234, 2, 234, 2, 120, 1, 120, 1,+ 254, 255, 254, 255, 132, 254, 132, 254, 17, 253, 17, 253, 171, 251, 171,+ 251, 88, 250, 88, 250, 30, 249, 30, 249, 1, 248, 1, 248, 8, 247, 8, 247,+ 54, 246, 54, 246, 142, 245, 142, 245, 21, 245, 21, 245, 203, 244, 203,+ 244, 179, 244, 179, 244, 203, 244, 203, 244, 21, 245, 21, 245, 143, 245,+ 143, 245, 55, 246, 55, 246, 9, 247, 9, 247, 3, 248, 3, 248, 31, 249, 31,+ 249, 90, 250, 90, 250, 173, 251, 173, 251, 18, 253, 18, 253, 133, 254,+ 133, 254, 255, 255, 255, 255, 120, 1, 120, 1, 236, 2, 236, 2, 82, 4, 82,+ 4, 165, 5, 165, 5, 224, 6, 224, 6, 252, 7, 252, 7, 246, 8, 246, 8, 200, 9,+ 200, 9, 111, 10, 111, 10, 233, 10, 233, 10, 51, 11, 51, 11, 75, 11, 75,+ 11, 50, 11, 50, 11, 233, 10, 233, 10, 111, 10, 111, 10, 199, 9, 199, 9,+ 245, 8, 245, 8, 252, 7, 252, 7, 223, 6, 223, 6, 165, 5, 165, 5, 82, 4, 82,+ 4, 236, 2, 236, 2, 121, 1, 121, 1, 255, 255, 255, 255, 134, 254, 134, 254,+ 19, 253, 19, 253, 173, 251, 173, 251, 89, 250, 89, 250, 31, 249, 31, 249,+ 2, 248, 2, 248, 9, 247, 9, 247, 54, 246, 54, 246, 143, 245, 143, 245, 21,+ 245, 21, 245, 203, 244, 203, 244, 178, 244, 178, 244, 203, 244, 203, 244,+ 20, 245, 20, 245, 142, 245, 142, 245, 53, 246, 53, 246, 7, 247, 7, 247, 1,+ 248, 1, 248, 30, 249, 30, 249, 87, 250, 87, 250, 171, 251, 171, 251, 17,+ 253, 17, 253, 132, 254, 132, 254, 254, 255, 254, 255, 119, 1, 119, 1, 235,+ 2, 235, 2, 82, 4, 82, 4, 164, 5, 164, 5, 223, 6, 223, 6, 252, 7, 252, 7,+ 246, 8, 246, 8, 200, 9, 200, 9, 112, 10, 112, 10, 234, 10, 234, 10, 52,+ 11, 52, 11, 77, 11, 77, 11, 52, 11, 52, 11, 234, 10, 234, 10, 113, 10,+ 113, 10, 201, 9, 201, 9, 247, 8, 247, 8, 254, 7, 254, 7, 225, 6, 225, 6,+ 166, 5, 166, 5, 83, 4, 83, 4, 237, 2, 237, 2, 122, 1, 122, 1, 1, 0, 1, 0,+ 135, 254, 135, 254, 20, 253, 20, 253, 173, 251, 173, 251, 90, 250, 90,+ 250, 31, 249, 31, 249, 2, 248, 2, 248, 9, 247, 9, 247, 54, 246, 54, 246,+ 142, 245, 142, 245, 21, 245, 21, 245, 202, 244, 202, 244, 177, 244, 177,+ 244, 202, 244, 202, 244, 19, 245, 19, 245, 141, 245, 141, 245, 52, 246,+ 52, 246, 6, 247, 6, 247, 255, 247, 255, 247, 28, 249, 28, 249, 87, 250,+ 87, 250, 170, 251, 170, 251, 16, 253, 16, 253, 132, 254, 132, 254, 253,+ 255, 253, 255, 119, 1, 119, 1, 235, 2, 235, 2, 82, 4, 82, 4, 165, 5, 165,+ 5, 224, 6, 224, 6, 253, 7, 253, 7, 247, 8, 247, 8, 201, 9, 201, 9, 113,+ 10, 113, 10, 236, 10, 236, 10, 53, 11, 53, 11, 78, 11, 78, 11, 53, 11, 53,+ 11, 236, 10, 236, 10, 114, 10, 114, 10, 203, 9, 203, 9, 249, 8, 249, 8,+ 255, 7, 255, 7, 226, 6, 226, 6, 168, 5, 168, 5, 84, 4, 84, 4, 238, 2, 238,+ 2, 123, 1, 123, 1, 1, 0, 1, 0, 134, 254, 134, 254, 18, 253, 18, 253, 172,+ 251, 172, 251, 89, 250, 89, 250, 29, 249, 29, 249, 0, 248, 0, 248, 7, 247,+ 7, 247, 52, 246, 52, 246, 140, 245, 140, 245, 18, 245, 18, 245, 201, 244,+ 201, 244, 176, 244, 176, 244, 201, 244, 201, 244, 18, 245, 18, 245, 139,+ 245, 139, 245, 51, 246, 51, 246, 6, 247, 6, 247, 255, 247, 255, 247, 28,+ 249, 28, 249, 86, 250, 86, 250, 170, 251, 170, 251, 17, 253, 17, 253, 132,+ 254, 132, 254, 254, 255, 254, 255, 120, 1, 120, 1, 236, 2, 236, 2, 82, 4,+ 82, 4, 166, 5, 166, 5, 225, 6, 225, 6, 255, 7, 255, 7, 248, 8, 248, 8,+ 203, 9, 203, 9, 115, 10, 115, 10, 236, 10, 236, 10, 53, 11, 53, 11, 79,+ 11, 79, 11, 54, 11, 54, 11, 237, 10, 237, 10, 115, 10, 115, 10, 204, 9,+ 204, 9, 249, 8, 249, 8, 255, 7, 255, 7, 226, 6, 226, 6, 168, 5, 168, 5,+ 84, 4, 84, 4, 237, 2, 237, 2, 121, 1, 121, 1, 255, 255, 255, 255, 133,+ 254, 133, 254, 17, 253, 17, 253, 171, 251, 171, 251, 88, 250, 88, 250, 28,+ 249, 28, 249, 254, 247, 254, 247, 5, 247, 5, 247, 51, 246, 51, 246, 139,+ 245, 139, 245, 17, 245, 17, 245, 200, 244, 200, 244, 176, 244, 176, 244,+ 200, 244, 200, 244, 17, 245, 17, 245, 140, 245, 140, 245, 51, 246, 51,+ 246, 6, 247, 6, 247, 0, 248, 0, 248, 28, 249, 28, 249, 87, 250, 87, 250,+ 172, 251, 172, 251, 18, 253, 18, 253, 134, 254, 134, 254, 0, 0, 0, 0, 122,+ 1, 122, 1, 237, 2, 237, 2, 83, 4, 83, 4, 167, 5, 167, 5, 226, 6, 226, 6,+ 255, 7, 255, 7, 249, 8, 249, 8, 204, 9,+ ]),+ );++ // unlinkSync(wav);});diff --git a/packages/renderer/src/assets/download-map.ts b/packages/renderer/src/assets/download-map.tsindex 84e2bd32e3..789f59bf94 100644--- a/packages/renderer/src/assets/download-map.ts+++ b/packages/renderer/src/assets/download-map.ts@@ -50,6 +50,7 @@ export type RenderAssetInfo = {imageSequenceName: string;firstFrameIndex: number;downloadMap: DownloadMap;+ compositionStart: number;};const makeAndReturn = (dir: string, name: string) => {diff --git a/packages/renderer/src/calculate-ffmpeg-filters.ts b/packages/renderer/src/calculate-ffmpeg-filters.tsindex ccd9d62e1f..8ceaf4a9bd 100644--- a/packages/renderer/src/calculate-ffmpeg-filters.ts+++ b/packages/renderer/src/calculate-ffmpeg-filters.ts@@ -12,6 +12,8 @@ export const calculateFfmpegFilter = ({channels,assetDuration,forSeamlessAacConcatenation,+ compositionStart,+ chunkStart,}: {asset: MediaAsset;fps: number;@@ -19,6 +21,8 @@ export const calculateFfmpegFilter = ({channels: number;assetDuration: number | null;forSeamlessAacConcatenation: boolean;+ compositionStart: number;+ chunkStart: number;}): FilterWithoutPaddingApplied | null => {if (channels === 0) {return null;@@ -28,7 +32,9 @@ export const calculateFfmpegFilter = ({? Math.max(0,getClosestAlignedTime(- ((asset.trimLeft * asset.playbackRate) / fps) * 1_000_000,+ (asset.trimLeft * asset.playbackRate) / fps,+ compositionStart,+ true,) /1_000_000 -2 * (1024 / DEFAULT_SAMPLE_RATE),@@ -36,13 +42,23 @@ export const calculateFfmpegFilter = ({: (asset.trimLeft * asset.playbackRate) / fps;const assetTrimRight = forSeamlessAacConcatenation? getClosestAlignedTime(- ((asset.trimLeft + asset.duration * asset.playbackRate) / fps) *- 1_000_000,+ (asset.trimLeft + asset.duration * asset.playbackRate) / fps,+ compositionStart,+ true,) /1_000_000 +2 * (1024 / DEFAULT_SAMPLE_RATE): assetTrimLeft + (asset.duration * asset.playbackRate) / fps;+ console.log({+ assetTrimLeft,+ assetTrimRight,+ asset,+ targetRight:+ ((asset.trimLeft + asset.duration * asset.playbackRate) / fps) *+ 1_000_000,+ });+return stringifyFfmpegFilter({channels,startInVideo: asset.startInVideo,diff --git a/packages/renderer/src/combine-audio.ts b/packages/renderer/src/combine-audio.tsindex 29b4f01407..41ee0735ae 100644--- a/packages/renderer/src/combine-audio.ts+++ b/packages/renderer/src/combine-audio.ts@@ -13,10 +13,21 @@ import {truthy} from './truthy';export const durationOf1Frame = (1024 / DEFAULT_SAMPLE_RATE) * 1_000_000;-export const getClosestAlignedTime = (targetTime: number) => {- const decimalFramesToTargetTime = targetTime / durationOf1Frame;+export const getClosestAlignedTime = (+ targetTime: number,+ compositionStart: number,+ _override: boolean,+) => {+ if (_override) {+ compositionStart = 3.333333;+ }++ const decimalFramesToTargetTime = (targetTime * 1_000_000) / durationOf1Frame;const nearestFrameIndexForTargetTime = Math.round(decimalFramesToTargetTime);- return nearestFrameIndexForTargetTime * durationOf1Frame;+ return (+ nearestFrameIndexForTargetTime * durationOf1Frame ++ compositionStart * 1_000_000+ );};const encodeAudio = async ({@@ -136,13 +147,14 @@ const combineAudioSeamlessly = async ({const fileList = files.map((p, i) => {const isLast = i === files.length - 1;- const targetStart = i * chunkDurationInSeconds * 1_000_000;- const endStart = (i + 1) * chunkDurationInSeconds * 1_000_000;+ const targetStart = i * chunkDurationInSeconds;+ const endStart = (i + 1) * chunkDurationInSeconds;- const startTime = getClosestAlignedTime(targetStart);- const endTime = getClosestAlignedTime(endStart);+ const startTime = getClosestAlignedTime(targetStart, 0, false);+ const endTime = getClosestAlignedTime(endStart, 0, false);const realDuration = endTime - startTime;+ console.log({realDuration, chunkDurationInSeconds});let inpoint = 0;if (i > 0) {@@ -167,6 +179,8 @@ const combineAudioSeamlessly = async ({}).join('\n');+ console.log(fileList);+const fileListTxt = join(filelistDir, 'audio-files.txt');writeFileSync(fileListTxt, fileList);diff --git a/packages/renderer/src/create-audio.ts b/packages/renderer/src/create-audio.tsindex d7484276d0..0bb35213f7 100644--- a/packages/renderer/src/create-audio.ts+++ b/packages/renderer/src/create-audio.ts@@ -32,6 +32,7 @@ export const createAudio = async ({audioCodec,cancelSignal,forSeamlessAacConcatenation,+ compositionStart,}: {assets: TRenderAsset[][];onDownload: RenderMediaOnDownload | undefined;@@ -47,6 +48,7 @@ export const createAudio = async ({audioCodec: AudioCodec;cancelSignal: CancelSignal | undefined;forSeamlessAacConcatenation: boolean;+ compositionStart: number;}): Promise<string> => {const fileUrlAssets = await convertAssetsToFileUrls({assets,@@ -99,6 +101,7 @@ export const createAudio = async ({preprocessProgress[index] = progress;updateProgress();},+ compositionStart,});preprocessProgress[index] = 1;updateProgress();diff --git a/packages/renderer/src/preprocess-audio-track.ts b/packages/renderer/src/preprocess-audio-track.tsindex b2d3e2240e..d2eb0c83dd 100644--- a/packages/renderer/src/preprocess-audio-track.ts+++ b/packages/renderer/src/preprocess-audio-track.ts@@ -24,6 +24,7 @@ type Options = {binariesDirectory: string | null;cancelSignal: CancelSignal | undefined;forSeamlessAacConcatenation: boolean;+ compositionStart: number;onProgress: (progress: number) => void;};@@ -44,6 +45,7 @@ const preprocessAudioTrackUnlimited = async ({cancelSignal,forSeamlessAacConcatenation,onProgress,+ compositionStart,}: Options): Promise<PreprocessedAudioTrack | null> => {const {channels, duration} = await getAudioChannelsAndDuration({downloadMap,@@ -61,6 +63,7 @@ const preprocessAudioTrackUnlimited = async ({channels,assetDuration: duration,forSeamlessAacConcatenation,+ compositionStart,});if (filter === null) {diff --git a/packages/renderer/src/render-frames.ts b/packages/renderer/src/render-frames.tsindex 8ae19ccced..0e3dc6c945 100644--- a/packages/renderer/src/render-frames.ts+++ b/packages/renderer/src/render-frames.ts@@ -577,6 +577,8 @@ const innerRenderFrames = async ({),firstFrameIndex,downloadMap,+ compositionStart:+ frameRange === null ? 0 : realFrameRange[0] / composition.fps,},frameCount: framesToRender.length,};diff --git a/packages/renderer/src/stitch-frames-to-video.ts b/packages/renderer/src/stitch-frames-to-video.tsindex 839bf67ed9..1e652d2701 100644--- a/packages/renderer/src/stitch-frames-to-video.ts+++ b/packages/renderer/src/stitch-frames-to-video.ts@@ -269,6 +269,7 @@ const innerStitchFramesToVideo = async (audioCodec: resolvedAudioCodec,cancelSignal: cancelSignal ?? undefined,forSeamlessAacConcatenation,+ compositionStart: assetsInfo.compositionStart,}): null;diff --git a/packages/renderer/src/test/ffmpeg-filters.test.ts b/packages/renderer/src/test/ffmpeg-filters.test.tsindex 6511295fc4..6db78387b2 100644--- a/packages/renderer/src/test/ffmpeg-filters.test.ts+++ b/packages/renderer/src/test/ffmpeg-filters.test.ts@@ -30,6 +30,7 @@ test('Should create a basic filter correctly', () => {channels: 1,assetDuration: 10,forSeamlessAacConcatenation: true,+ compositionStart: 0,}),).toEqual({filter:@@ -47,6 +48,7 @@ test('Trim the end', () => {channels: 1,assetDuration: 10,forSeamlessAacConcatenation: true,+ compositionStart: 0,}),).toEqual({filter:@@ -68,6 +70,7 @@ test('Should handle trim correctly', () => {channels: 1,assetDuration: 10,forSeamlessAacConcatenation: true,+ compositionStart: 0,}),).toEqual({filter:@@ -89,6 +92,7 @@ test('Should add padding if audio is too short', () => {channels: 1,assetDuration: 1,forSeamlessAacConcatenation: false,+ compositionStart: 0,}),).toEqual({filter:@@ -112,6 +116,7 @@ test('Should handle delay correctly', () => {channels: 1,assetDuration: 1,forSeamlessAacConcatenation: true,+ compositionStart: 0,}),).toEqual({filter:@@ -134,6 +139,7 @@ test('Should offset multiple channels', () => {channels: 3,assetDuration: 1,forSeamlessAacConcatenation: true,+ compositionStart: 0,}),).toEqual({filter:@@ -166,6 +172,7 @@ test('Should calculate pad correctly with a lot of playbackRate', () => {channels: 1,assetDuration: 33.333333,forSeamlessAacConcatenation: true,+ compositionStart: 0,}),).toEqual({filter: