🎥 Make videos programmatically with React
import {expect, test} from 'bun:test';
import {makeLambdaRenderMediaPayload} from '../make-lambda-payload';
import {ServerlessRoutines} from '../shared-constants';
test('Should include concurrency field in payload', async () => {
const payload = await makeLambdaRenderMediaPayload({
output: {type: 'media'},
enableCancellation: false,
region: 'us-east-1',
functionName: 'test-function',
serveUrl: 'https://example.com',
composition: 'test-composition',
inputProps: {},
codec: 'h264',
imageFormat: 'jpeg',
crf: undefined,
envVariables: {},
pixelFormat: undefined,
proResProfile: undefined,
x264Preset: null,
gopSize: null,
disableSharedMemoryCapture: false,
privacy: 'public',
jpegQuality: 80,
maxRetries: 1,
framesPerLambda: null,
concurrency: 10,
logLevel: 'info',
frameRange: null,
outName: null,
separateAudioTo: null,
timeoutInMilliseconds: 30000,
chromiumOptions: {},
scale: 1,
everyNthFrame: 1,
numberOfGifLoops: null,
concurrencyPerLambda: 1,
downloadBehavior: {type: 'play-in-browser'},
muted: false,
overwrite: false,
audioBitrate: null,
videoBitrate: null,
encodingMaxRate: null,
encodingBufferSize: null,
webhook: null,
forceHeight: null,
forceWidth: null,
forceFps: null,
forceDurationInFrames: null,
rendererFunctionName: null,
forceBucketName: null,
audioCodec: null,
colorSpace: null,
deleteAfter: null,
indent: false,
forcePathStyle: false,
metadata: null,
licenseKey: null,
offthreadVideoCacheSizeInBytes: null,
mediaCacheSizeInBytes: null,
offthreadVideoThreads: null,
storageClass: null,
requestHandler: null,
preferLossless: false,
isProduction: null,
sampleRate: 48000,
});
expect(payload.type).toBe(ServerlessRoutines.start);
expect(payload.concurrency).toBe(10);
});
test('Should handle null concurrency', async () => {
const payload = await makeLambdaRenderMediaPayload({
output: {type: 'media'},
enableCancellation: false,
region: 'us-east-1',
functionName: 'test-function',
serveUrl: 'https://example.com',
composition: 'test-composition',
inputProps: {},
codec: 'h264',
imageFormat: 'jpeg',
crf: undefined,
envVariables: {},
pixelFormat: undefined,
proResProfile: undefined,
x264Preset: null,
gopSize: null,
disableSharedMemoryCapture: false,
privacy: 'public',
jpegQuality: 80,
maxRetries: 1,
framesPerLambda: null,
concurrency: null,
logLevel: 'info',
frameRange: null,
outName: null,
separateAudioTo: null,
timeoutInMilliseconds: 30000,
chromiumOptions: {},
scale: 1,
everyNthFrame: 1,
numberOfGifLoops: null,
concurrencyPerLambda: 1,
downloadBehavior: {type: 'play-in-browser'},
muted: false,
overwrite: false,
audioBitrate: null,
videoBitrate: null,
encodingMaxRate: null,
encodingBufferSize: null,
webhook: null,
forceHeight: null,
forceWidth: null,
forceFps: null,
forceDurationInFrames: null,
rendererFunctionName: null,
forceBucketName: null,
audioCodec: null,
colorSpace: null,
deleteAfter: null,
indent: false,
forcePathStyle: false,
metadata: null,
licenseKey: null,
offthreadVideoCacheSizeInBytes: null,
mediaCacheSizeInBytes: null,
offthreadVideoThreads: null,
storageClass: null,
requestHandler: null,
preferLossless: false,
isProduction: null,
sampleRate: 48000,
});
expect(payload.type).toBe(ServerlessRoutines.start);
expect(payload.concurrency).toBe(null);
});