Skip to content

🎥 Make videos programmatically with React

math checks out!

Jonny Burger4e678f46fae5
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index f25e907e60..dbc5ae7bbd 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -242,6 +242,8 @@ const innerLaunchHandler = async ({
needsToUpload,
});
+ const fps = comp.fps / params.everyNthFrame;
+
const lambdaPayloads = chunks.map((chunkPayload) => {
const payload: LambdaPayload = {
type: LambdaRoutines.renderer,
@@ -286,7 +288,7 @@ const innerLaunchHandler = async ({
deleteAfter: params.deleteAfter,
colorSpace: params.colorSpace,
preferLossless: params.preferLossless,
- compositionStart: realFrameRange[0],
+ compositionStart: realFrameRange[0] / fps,
};
return payload;
});
@@ -385,7 +387,6 @@ const innerLaunchHandler = async ({
reqSend.end();
- const fps = comp.fps / params.everyNthFrame;
const postRenderData = await mergeChunksAndFinishRender({
bucketName: params.bucketName,
renderId: params.renderId,
diff --git a/packages/lambda/src/test/integration/renders/seamless-audio.test.ts b/packages/lambda/src/test/integration/renders/seamless-audio.test.ts
index 87991b3746..31ced0394f 100644
--- a/packages/lambda/src/test/integration/renders/seamless-audio.test.ts
+++ b/packages/lambda/src/test/integration/renders/seamless-audio.test.ts
@@ -17,7 +17,7 @@ test('Should make seamless audio', async () => {
composition: 'framer',
frameRange: [100, 200],
imageFormat: 'png',
- logLevel: 'verbose',
+ logLevel: 'error',
region: 'eu-central-1',
});
diff --git a/packages/renderer/src/calculate-ffmpeg-filters.ts b/packages/renderer/src/calculate-ffmpeg-filters.ts
index 0a12c40146..f743987a0f 100644
--- a/packages/renderer/src/calculate-ffmpeg-filters.ts
+++ b/packages/renderer/src/calculate-ffmpeg-filters.ts
@@ -31,26 +31,30 @@ export const calculateFfmpegFilter = ({
const realLeftEnd = chunkStart - compositionStart;
const realRightEnd = realLeftEnd + durationInFrames / fps;
- const actualLeftEnd =
- getClosestAlignedTime(realLeftEnd) - 2 * (1024 / DEFAULT_SAMPLE_RATE);
- const actualRightEnd =
+ const aacAdjustedLeftEnd = Math.max(
+ 0,
+ getClosestAlignedTime(realLeftEnd) - 2 * (1024 / DEFAULT_SAMPLE_RATE),
+ );
+ const aacAdjustedRightEnd =
getClosestAlignedTime(realRightEnd) + 2 * (1024 / DEFAULT_SAMPLE_RATE);
- console.log({actualLeftEnd, actualRightEnd});
+ const aacAdjustedLeft = forSeamlessAacConcatenation
+ ? aacAdjustedLeftEnd - realLeftEnd
+ : 0;
+ const aacAdjustedRight = forSeamlessAacConcatenation
+ ? aacAdjustedRightEnd - realRightEnd
+ : 0;
+
+ const normalTrimLeft = (asset.trimLeft * asset.playbackRate) / fps;
+ const normalTrimRight =
+ ((asset.trimLeft + asset.duration) * asset.playbackRate) / fps;
const assetTrimLeft = forSeamlessAacConcatenation
- ? Math.max(
- 0,
- getClosestAlignedTime((asset.trimLeft * asset.playbackRate) / fps) -
- 2 * (1024 / DEFAULT_SAMPLE_RATE),
- )
- : (asset.trimLeft * asset.playbackRate) / fps;
+ ? normalTrimLeft + aacAdjustedLeft
+ : normalTrimLeft;
const assetTrimRight = forSeamlessAacConcatenation
- ? getClosestAlignedTime(
- ((asset.trimLeft + asset.duration) * asset.playbackRate) / fps,
- ) +
- 2 * (1024 / DEFAULT_SAMPLE_RATE)
- : assetTrimLeft + (asset.duration * asset.playbackRate) / fps;
+ ? normalTrimRight + aacAdjustedRight
+ : normalTrimRight;
return stringifyFfmpegFilter({
channels,