Skip to content

🎥 Make videos programmatically with React

some fixes

Jonny Burger2906cfafdd84
diff --git a/packages/renderer/src/get-cpu-count.ts b/packages/renderer/src/get-cpu-count.ts
index 93add1d7a8..392d75d7b6 100644
--- a/packages/renderer/src/get-cpu-count.ts
+++ b/packages/renderer/src/get-cpu-count.ts
@@ -6,7 +6,7 @@ import {execSync} from 'node:child_process';
import {cpus} from 'node:os';
// We also get it from nproc and use the minimum of the two.
-const getConcurrencyFromNProc = (): number | null => {
+export const getConcurrencyFromNProc = (): number | null => {
try {
return parseInt(execSync('nproc', {stdio: 'pipe'}).toString().trim(), 10);
} catch (error) {
diff --git a/packages/renderer/src/test/actual-concurrency.test.ts b/packages/renderer/src/test/actual-concurrency.test.ts
index d87c71fd35..499f6a14a5 100644
--- a/packages/renderer/src/test/actual-concurrency.test.ts
+++ b/packages/renderer/src/test/actual-concurrency.test.ts
@@ -1,25 +1,33 @@
import {expect, test} from 'bun:test';
-import os from 'node:os';
import {getActualConcurrency} from '../get-concurrency';
+import {getConcurrencyFromNProc} from '../get-cpu-count';
test('Actual concurrency null should choose a good result', () => {
expect(getActualConcurrency(null)).toBe(
- Math.round(Math.min(8, Math.max(1, os.cpus().length / 2))),
+ Math.round(
+ Math.min(8, Math.max(1, (getConcurrencyFromNProc() as number) / 2)),
+ ),
);
});
test('50% should yield half the cores', () => {
expect(getActualConcurrency('50%')).toBe(
- Math.floor(Math.min(8, Math.max(1, os.cpus().length / 2))),
+ Math.floor(
+ Math.min(8, Math.max(1, (getConcurrencyFromNProc() as number) / 2)),
+ ),
);
});
test('75% should be 3/4 of the cores', () => {
- expect(getActualConcurrency('75%')).toBe(Math.floor(os.cpus().length * 0.75));
+ expect(getActualConcurrency('75%')).toBe(
+ Math.floor((getConcurrencyFromNProc() as number) * 0.75),
+ );
});
test('Slightly over 100% is ok as long as it is rounded', () => {
- expect(getActualConcurrency('100.2%')).toBe(os.cpus().length);
+ expect(getActualConcurrency('100.2%')).toBe(
+ getConcurrencyFromNProc() as number,
+ );
});
test('Should also accept integers', () => {
diff --git a/packages/renderer/src/test/extract-frame-rust.test.ts b/packages/renderer/src/test/extract-frame-rust.test.ts
index fa32ade72c..32a5260b1c 100644
--- a/packages/renderer/src/test/extract-frame-rust.test.ts
+++ b/packages/renderer/src/test/extract-frame-rust.test.ts
@@ -477,27 +477,33 @@ test('Should get from broken webcam video', async () => {
await compositor.waitForDone();
});
-test('Should get from iPhone video', async () => {
- const compositor = startLongRunningCompositor({
- maximumFrameCacheItemsInBytes: null,
- logLevel: 'info',
- indent: false,
- binariesDirectory: null,
- });
+test(
+ 'Should get from iPhone video',
+ async () => {
+ const compositor = startLongRunningCompositor({
+ maximumFrameCacheItemsInBytes: null,
+ logLevel: 'info',
+ indent: false,
+ binariesDirectory: null,
+ });
- const data = await compositor.executeCommand('ExtractFrame', {
- src: exampleVideos.iphonevideo,
- original_src: exampleVideos.iphonevideo,
- time: 1,
- transparent: false,
- tone_mapped: true,
- });
+ const data = await compositor.executeCommand('ExtractFrame', {
+ src: exampleVideos.iphonevideo,
+ original_src: exampleVideos.iphonevideo,
+ time: 1,
+ transparent: false,
+ tone_mapped: true,
+ });
- expect(data.length).toBe(24883254);
+ expect(data.length).toBe(24883254);
- await compositor.finishCommands();
- await compositor.waitForDone();
-});
+ await compositor.finishCommands();
+ await compositor.waitForDone();
+ },
+ {
+ timeout: 30000,
+ },
+);
test('Should get from AV1 video', async () => {
const compositor = startLongRunningCompositor({