Skip to content

🎥 Make videos programmatically with React

can use more memory

Jonny Burgerad66468e714b
diff --git a/packages/renderer/rust/main.rs b/packages/renderer/rust/main.rs
index 63056e6b6c..ef2850cbfa 100644
--- a/packages/renderer/rust/main.rs
+++ b/packages/renderer/rust/main.rs
@@ -18,7 +18,7 @@ mod scalable_frame;
use commands::execute_command;
use errors::{error_to_json, ErrorWithBacktrace};
use global_printer::{_print_verbose, set_verbose_logging};
-use memory::is_about_to_run_out_of_memory;
+use memory::{get_ideal_maximum_frame_cache_size, is_about_to_run_out_of_memory};
use std::env;
use payloads::payloads::{parse_cli, CliInputCommand, CliInputCommandPayload};
@@ -42,19 +42,17 @@ fn mainfn() -> Result<(), ErrorWithBacktrace> {
CliInputCommandPayload::StartLongRunningProcess(payload) => {
set_verbose_logging(payload.verbose);
- let memory = memory::get_available_memory();
-
- _print_verbose(&format!("available memory {}", memory))?;
+ let max_video_cache_size = payload
+ .maximum_frame_cache_size_in_bytes
+ .unwrap_or(get_ideal_maximum_frame_cache_size());
_print_verbose(&format!(
"Starting Rust process. Max video cache size: {}MB, max concurrency = {}",
- payload.maximum_frame_cache_size_in_bytes / 1024 / 1024,
+ max_video_cache_size / 1024 / 1024,
payload.concurrency
))?;
- start_long_running_process(
- payload.concurrency,
- payload.maximum_frame_cache_size_in_bytes,
- )?;
+
+ start_long_running_process(payload.concurrency, max_video_cache_size)?;
}
_ => {
let data = execute_command(opts.payload)?;
diff --git a/packages/renderer/rust/memory.rs b/packages/renderer/rust/memory.rs
index e4292df3d0..0672bc6519 100644
--- a/packages/renderer/rust/memory.rs
+++ b/packages/renderer/rust/memory.rs
@@ -8,9 +8,18 @@ pub fn get_available_memory() -> u64 {
// Is there less than 100MB of memory left?
pub fn is_about_to_run_out_of_memory() -> bool {
- let mut sys = System::new();
- sys.refresh_memory();
+ return get_available_memory() < 100 * 1024 * 1024;
+}
+
+pub fn get_ideal_maximum_frame_cache_size() -> u128 {
+ let available_memory = get_available_memory();
+
+ // Take 40% of available memory
+ let max = available_memory * 2 / 5;
+
+ return max.max(mb_to_bytes(240)).min(mb_to_bytes(20_000)).into();
+}
- let free_memory_and_swap = sys.total_memory() - sys.used_memory();
- return free_memory_and_swap < 100 * 1024 * 1024;
+pub fn mb_to_bytes(mb: u64) -> u64 {
+ return mb * 1024 * 1024;
}
diff --git a/packages/renderer/rust/payloads.rs b/packages/renderer/rust/payloads.rs
index ca5f1db91c..c8fc3bc5a4 100644
--- a/packages/renderer/rust/payloads.rs
+++ b/packages/renderer/rust/payloads.rs
@@ -78,7 +78,7 @@ pub mod payloads {
#[derive(Serialize, Deserialize, Debug)]
pub struct StartPayLoad {
pub concurrency: usize,
- pub maximum_frame_cache_size_in_bytes: u128,
+ pub maximum_frame_cache_size_in_bytes: Option<u128>,
pub verbose: bool,
}
diff --git a/packages/renderer/src/compositor/compositor.ts b/packages/renderer/src/compositor/compositor.ts
index 9551b59c36..b6c53c300c 100644
--- a/packages/renderer/src/compositor/compositor.ts
+++ b/packages/renderer/src/compositor/compositor.ts
@@ -1,6 +1,5 @@
import {spawn} from 'node:child_process';
import {chmodSync} from 'node:fs';
-import os from 'node:os';
import {dynamicLibraryPathOptions} from '../call-ffmpeg';
import {getActualConcurrency} from '../get-concurrency';
import type {LogLevel} from '../log-level';
@@ -30,24 +29,15 @@ type Waiter = {
reject: (err: Error) => void;
};
-export const getIdealMaximumFrameCacheSizeInBytes = () => {
- const freeMemory = os.freemem();
-
- // Assuming only half the available memory should be used
- const max = freeMemory / 2;
-
- // Never store more than 2000 MB
- // But 240MB is needed even if it's going to swap
- return Math.max(mbToBytes(240), Math.min(max, mbToBytes(2000)));
-};
-
-const mbToBytes = (mb: number) => mb * 1024 * 1024;
-
-export const startLongRunningCompositor = (
- maximumFrameCacheItemsInBytes: number,
- logLevel: LogLevel,
- indent: boolean,
-) => {
+export const startLongRunningCompositor = ({
+ maximumFrameCacheItemsInBytes,
+ logLevel,
+ indent,
+}: {
+ maximumFrameCacheItemsInBytes: number | null;
+ logLevel: LogLevel;
+ indent: boolean;
+}) => {
return startCompositor(
'StartLongRunningProcess',
{
@@ -256,7 +246,7 @@ export const startCompositor = <T extends keyof CompositorCommand>(
resolve?.();
for (const waiter of waitersToKill) {
waiter.reject(
- new Error(`Compositor quit${signal ? ` with signal ${signal}` : ''}`)
+ new Error(`Compositor quit${signal ? ` with signal ${signal}` : ''}`),
);
}
@@ -291,8 +281,8 @@ export const startCompositor = <T extends keyof CompositorCommand>(
runningStatus.signal
? ` with signal ${runningStatus.signal}`
: ''
- }`
- )
+ }`,
+ ),
);
return;
}
@@ -304,8 +294,8 @@ export const startCompositor = <T extends keyof CompositorCommand>(
runningStatus.signal
? ` with signal ${runningStatus.signal}`
: ''
- }: ${runningStatus.error}`
- )
+ }: ${runningStatus.error}`,
+ ),
);
return;
}
@@ -319,7 +309,7 @@ export const startCompositor = <T extends keyof CompositorCommand>(
throw new Error(
`Compositor quit${
runningStatus.signal ? ` with signal ${runningStatus.signal}` : ''
- }: ${runningStatus.error}`
+ }: ${runningStatus.error}`,
);
}
@@ -327,7 +317,7 @@ export const startCompositor = <T extends keyof CompositorCommand>(
throw new Error(
`Compositor quit${
runningStatus.signal ? ` with signal ${runningStatus.signal}` : ''
- }`
+ }`,
);
}
@@ -342,7 +332,7 @@ export const startCompositor = <T extends keyof CompositorCommand>(
throw new Error(
`Compositor quit${
runningStatus.signal ? ` with signal ${runningStatus.signal}` : ''
- }`
+ }`,
);
}
diff --git a/packages/renderer/src/compositor/payloads.ts b/packages/renderer/src/compositor/payloads.ts
index 2526fbea81..031e148955 100644
--- a/packages/renderer/src/compositor/payloads.ts
+++ b/packages/renderer/src/compositor/payloads.ts
@@ -99,7 +99,7 @@ export type CompositorCommand = {
};
StartLongRunningProcess: {
concurrency: number;
- maximum_frame_cache_size_in_bytes: number;
+ maximum_frame_cache_size_in_bytes: number | null;
verbose: boolean;
};
CopyImageToClipboard: {
diff --git a/packages/renderer/src/copy-to-clipboard.ts b/packages/renderer/src/copy-to-clipboard.ts
index 74e7143c9b..ea12384978 100644
--- a/packages/renderer/src/copy-to-clipboard.ts
+++ b/packages/renderer/src/copy-to-clipboard.ts
@@ -1,15 +1,12 @@
-import {
- getIdealMaximumFrameCacheSizeInBytes,
- startLongRunningCompositor,
-} from './compositor/compositor';
+import {startLongRunningCompositor} from './compositor/compositor';
import type {LogLevel} from './log-level';
export const copyImageToClipboard = async (src: string, logLevel: LogLevel) => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
logLevel,
- false,
- );
+ indent: false,
+ });
await compositor.executeCommand('CopyImageToClipboard', {
src,
diff --git a/packages/renderer/src/get-silent-parts.ts b/packages/renderer/src/get-silent-parts.ts
index 519072f68b..1b66edbaf7 100644
--- a/packages/renderer/src/get-silent-parts.ts
+++ b/packages/renderer/src/get-silent-parts.ts
@@ -1,7 +1,4 @@
-import {
- getIdealMaximumFrameCacheSizeInBytes,
- startLongRunningCompositor,
-} from './compositor/compositor';
+import {startLongRunningCompositor} from './compositor/compositor';
import type {
GetSilentPartsResponse,
GetSilentPartsResponseRust,
@@ -20,11 +17,11 @@ export const getSilentParts = async ({
logLevel?: LogLevel;
noiseThresholdInDecibels?: number;
}): Promise<GetSilentPartsResponse> => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- logLevel ?? 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: logLevel ?? 'info',
+ indent: false,
+ });
const minDurationInSeconds = passedMinDuration ?? 1;
diff --git a/packages/renderer/src/get-video-metadata.ts b/packages/renderer/src/get-video-metadata.ts
index 2ff2cbf627..813ae63ab7 100644
--- a/packages/renderer/src/get-video-metadata.ts
+++ b/packages/renderer/src/get-video-metadata.ts
@@ -1,7 +1,4 @@
-import {
- getIdealMaximumFrameCacheSizeInBytes,
- startLongRunningCompositor,
-} from './compositor/compositor';
+import {startLongRunningCompositor} from './compositor/compositor';
import type {VideoMetadata} from './compositor/payloads';
import type {LogLevel} from './log-level';
@@ -9,11 +6,11 @@ export const getVideoMetadata = async (
videoSource: string,
options?: {logLevel?: LogLevel},
): Promise<VideoMetadata> => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- options?.logLevel ?? 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: options?.logLevel ?? 'info',
+ indent: false,
+ });
const metadataResponse = await compositor.executeCommand('GetVideoMetadata', {
src: videoSource,
});
diff --git a/packages/renderer/src/offthread-video-server.ts b/packages/renderer/src/offthread-video-server.ts
index a282d8e376..3c0a4e4cc3 100644
--- a/packages/renderer/src/offthread-video-server.ts
+++ b/packages/renderer/src/offthread-video-server.ts
@@ -3,10 +3,7 @@ import {URLSearchParams} from 'node:url';
import {downloadAsset} from './assets/download-and-map-assets-to-file';
import type {DownloadMap} from './assets/download-map';
import type {Compositor} from './compositor/compositor';
-import {
- getIdealMaximumFrameCacheSizeInBytes,
- startCompositor,
-} from './compositor/compositor';
+import {startCompositor} from './compositor/compositor';
import type {LogLevel} from './log-level';
import {isEqualOrBelowLogLevel} from './log-level';
import {Log} from './logger';
@@ -65,9 +62,7 @@ export const startOffthreadVideoServer = ({
'StartLongRunningProcess',
{
concurrency,
- maximum_frame_cache_size_in_bytes:
- offthreadVideoCacheSizeInBytes ??
- getIdealMaximumFrameCacheSizeInBytes(),
+ maximum_frame_cache_size_in_bytes: offthreadVideoCacheSizeInBytes,
verbose: isEqualOrBelowLogLevel(logLevel, 'verbose'),
},
logLevel,
diff --git a/packages/renderer/src/test/compositor-rust.test.ts b/packages/renderer/src/test/compositor-rust.test.ts
index fe718c7f55..93d036f418 100644
--- a/packages/renderer/src/test/compositor-rust.test.ts
+++ b/packages/renderer/src/test/compositor-rust.test.ts
@@ -1,17 +1,14 @@
import {expect, test} from 'vitest';
-import {
- getIdealMaximumFrameCacheSizeInBytes,
- startLongRunningCompositor,
-} from '../compositor/compositor';
+import {startLongRunningCompositor} from '../compositor/compositor';
test(
'Compositor should process messages in the right order',
async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'verbose',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'verbose',
+ indent: false,
+ });
const matching = await Promise.all(
new Array(100).fill(true).map(async (_, i) => {
diff --git a/packages/renderer/src/test/extract-frame-rust.test.ts b/packages/renderer/src/test/extract-frame-rust.test.ts
index 2829207efc..b94d2dfc0c 100644
--- a/packages/renderer/src/test/extract-frame-rust.test.ts
+++ b/packages/renderer/src/test/extract-frame-rust.test.ts
@@ -1,9 +1,6 @@
import {interpolate} from 'remotion';
import {expect, test} from 'vitest';
-import {
- getIdealMaximumFrameCacheSizeInBytes,
- startLongRunningCompositor,
-} from '../compositor/compositor';
+import {startLongRunningCompositor} from '../compositor/compositor';
import {exampleVideos} from './example-videos';
const BMP_HEADER_SIZE = 54;
@@ -11,11 +8,11 @@ const BMP_HEADER_SIZE = 54;
test(
'Should be able to extract a frame using Rust',
async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.bigBuckBunny,
@@ -44,11 +41,11 @@ test(
test(
'Should be able to get a PNG',
async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.transparentWebm,
@@ -78,17 +75,17 @@ test(
);
test('Should be able to start two compositors', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
- const compositor2 = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor2 = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.bigBuckBunny,
@@ -105,11 +102,11 @@ test('Should be able to start two compositors', async () => {
});
test('Should be able to seek backwards', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.bigBuckBunny,
@@ -133,11 +130,11 @@ test('Should be able to seek backwards', async () => {
test(
'Should be able to extract a frame that has no file extension',
async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.framerWithoutFileExtension,
@@ -156,11 +153,11 @@ test(
test(
'Should get the last frame if out of range',
async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.framerWithoutFileExtension,
@@ -188,11 +185,11 @@ test(
test(
'Should get the last frame of a corrupted video',
async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.corrupted,
@@ -214,11 +211,11 @@ test(
);
test('Should be able to extract a frame with abnormal DAR', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.customDar,
@@ -244,11 +241,11 @@ test('Should be able to extract a frame with abnormal DAR', async () => {
});
test('Should be able to extract the frames in reverse order', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
let prevPixel = '';
@@ -288,11 +285,11 @@ test('Should be able to extract the frames in reverse order', async () => {
});
test('Last frame should be fast', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const time = Date.now();
@@ -351,11 +348,11 @@ test('Last frame should be fast', async () => {
});
test('Should get from a screen recording', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.screenrecording,
@@ -371,11 +368,11 @@ test('Should get from a screen recording', async () => {
});
test('Should get from video with no fps', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.nofps,
@@ -391,11 +388,11 @@ test('Should get from video with no fps', async () => {
});
test('Should get from broken webcam video', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.webcam,
@@ -411,11 +408,11 @@ test('Should get from broken webcam video', async () => {
});
test('Should get from iPhone video', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.iphonevideo,
@@ -431,11 +428,11 @@ test('Should get from iPhone video', async () => {
});
test('Should get from AV1 video', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.av1,
@@ -451,11 +448,11 @@ test('Should get from AV1 video', async () => {
});
test('Should handle getting a frame from a WebM when it is not transparent', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.variablefps,
@@ -475,11 +472,11 @@ test('Should handle getting a frame from a WebM when it is not transparent', asy
});
test('Should handle a video with no frames at the beginning', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const data = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.zerotimestamp,
@@ -499,11 +496,11 @@ test('Should handle a video with no frames at the beginning', async () => {
});
test('Two different starting times should not result in big seeking', async () => {
- const compositor = startLongRunningCompositor(
- 300 * 1024 * 1024,
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: 300 * 1024 * 1024,
+ logLevel: 'info',
+ indent: false,
+ });
const expected = [];
@@ -606,7 +603,11 @@ test('Should not duplicate frames for iphoneVideo', async () => {
startFrom: 0,
}) / 30;
- const compositor = startLongRunningCompositor(500, 'info', false);
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: 500,
+ logLevel: 'info',
+ indent: false,
+ });
const firstFrame = await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.iphonevideo,
diff --git a/packages/renderer/src/test/rust-errors.test.ts b/packages/renderer/src/test/rust-errors.test.ts
index 581e97454a..33fbe943d8 100644
--- a/packages/renderer/src/test/rust-errors.test.ts
+++ b/packages/renderer/src/test/rust-errors.test.ts
@@ -1,17 +1,14 @@
import path from 'node:path';
import {expect, test} from 'vitest';
import {callCompositor, serializeCommand} from '../compositor/compose';
-import {
- getIdealMaximumFrameCacheSizeInBytes,
- startLongRunningCompositor,
-} from '../compositor/compositor';
+import {startLongRunningCompositor} from '../compositor/compositor';
test('Should get Rust errors in a good way', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
try {
await compositor.executeCommand('ExtractFrame', {
@@ -31,11 +28,11 @@ test('Should get Rust errors in a good way', async () => {
});
test('Handle panics', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
try {
await compositor.executeCommand('DeliberatePanic', {});
diff --git a/packages/renderer/src/test/rust-get-video-metadata.test.ts b/packages/renderer/src/test/rust-get-video-metadata.test.ts
index b4549d5124..973995abd4 100644
--- a/packages/renderer/src/test/rust-get-video-metadata.test.ts
+++ b/packages/renderer/src/test/rust-get-video-metadata.test.ts
@@ -1,17 +1,14 @@
import {existsSync} from 'node:fs';
import path from 'node:path';
import {expect, test} from 'vitest';
-import {
- getIdealMaximumFrameCacheSizeInBytes,
- startLongRunningCompositor,
-} from '../compositor/compositor';
+import {startLongRunningCompositor} from '../compositor/compositor';
test('Should return video metadata', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const videoFile = path.join(
__dirname,
@@ -41,11 +38,11 @@ test('Should return video metadata', async () => {
});
test('Should return an error due to non existing file', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
try {
await compositor.executeCommand('GetVideoMetadata', {
@@ -59,11 +56,11 @@ test('Should return an error due to non existing file', async () => {
});
test('Should return an error due to using a audio file', async () => {
- const compositor = startLongRunningCompositor(
- getIdealMaximumFrameCacheSizeInBytes(),
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ });
const audioFile = path.join(
__dirname,
diff --git a/packages/renderer/src/test/rust-memory-usage.test.ts b/packages/renderer/src/test/rust-memory-usage.test.ts
index e87b13ba7e..b199927c9b 100644
--- a/packages/renderer/src/test/rust-memory-usage.test.ts
+++ b/packages/renderer/src/test/rust-memory-usage.test.ts
@@ -8,11 +8,11 @@ test('Memory usage should be determined ', async () => {
return;
}
- const compositor = startLongRunningCompositor(
- 40 * 24 * 1024 * 1024,
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: 40 * 24 * 1024 * 1024,
+ logLevel: 'info',
+ indent: false,
+ });
expect(
getMemoryUsageByPid((compositor.pid as Number).toString()),
@@ -96,11 +96,11 @@ test('Memory usage should be determined ', async () => {
});
test('Should respect the maximum frame cache limit', async () => {
- const compositor = startLongRunningCompositor(
- 50 * 24 * 1024 * 1024,
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: 50 * 24 * 1024 * 1024,
+ logLevel: 'info',
+ indent: false,
+ });
await compositor.executeCommand('ExtractFrame', {
src: exampleVideos.bigBuckBunny,
@@ -123,11 +123,11 @@ test('Should be able to take commands for freeing up memory', async () => {
return;
}
- const compositor = startLongRunningCompositor(
- 100 * 24 * 1024 * 1024,
- 'info',
- false,
- );
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: 100 * 24 * 1024 * 1024,
+ logLevel: 'info',
+ indent: false,
+ });
expect(
getMemoryUsageByPid((compositor.pid as Number).toString()),