Skip to content

🎥 Make videos programmatically with React

two compositors

Jonny Burgerd94bd0d51f27
diff --git a/packages/renderer/rust/main.rs b/packages/renderer/rust/main.rs
index 2b9a191f3e..1711c21f9e 100644
--- a/packages/renderer/rust/main.rs
+++ b/packages/renderer/rust/main.rs
@@ -48,6 +48,8 @@ pub fn parse_init_command(json: &str) -> Result<CliInputCommand, PossibleErrors>
}
fn start_long_running_process() -> Result<(), PossibleErrors> {
+ let pool = ThreadPool::new(4);
+
loop {
let mut input = String::new();
let matched = match std::io::stdin().read_line(&mut input) {
@@ -62,9 +64,13 @@ fn start_long_running_process() -> Result<(), PossibleErrors> {
break;
}
let opts: CliInputCommand = parse_cli(&input).unwrap();
- execute_command(opts).unwrap();
+ pool.execute(move || {
+ execute_command(opts).unwrap();
+ });
}
+ pool.join();
+
Ok(())
}
diff --git a/packages/renderer/src/test/extract-frame-rust.test.ts b/packages/renderer/src/test/extract-frame-rust.test.ts
index d00488fd01..3d335910d4 100644
--- a/packages/renderer/src/test/extract-frame-rust.test.ts
+++ b/packages/renderer/src/test/extract-frame-rust.test.ts
@@ -58,3 +58,28 @@ test('Should be able to start two compositors', async () => {
time: 40,
});
});
+
+test('Should be able to start two compositors', async () => {
+ const compositor = startCompositor({
+ type: 'StartLongRunningProcess',
+ params: {
+ nonce: makeNonce(),
+ },
+ });
+
+ const compositor2 = startCompositor({
+ type: 'StartLongRunningProcess',
+ params: {
+ nonce: makeNonce(),
+ },
+ });
+
+ await compositor.executeCommand('ExtractFrame', {
+ input: '/Users/jonathanburger/Downloads/fullmovie.mp4',
+ time: 40,
+ });
+ await compositor2.executeCommand('ExtractFrame', {
+ input: '/Users/jonathanburger/Downloads/fullmovie.mp4',
+ time: 40,
+ });
+});