🎥 Make videos programmatically with React
minduration in seconds
Jonny Burger7a8087c3238c
diff --git a/packages/docs/docs/renderer/get-silent-parts.md b/packages/docs/docs/renderer/get-silent-parts.mdindex a6b38e20af..8dd497ed80 100644--- a/packages/docs/docs/renderer/get-silent-parts.md+++ b/packages/docs/docs/renderer/get-silent-parts.md@@ -23,7 +23,7 @@ import { getSilentParts } from "@remotion/renderer";const { silentParts, durationInSeconds } = await getSilentParts({src: "./bunny.mp4",noiseThresholdInDecibels: -20,- minDuration: 1,+ minDurationInSeconds: 1,});console.log(silentParts); // [{startInSeconds: 0, endInSeconds: 1.5}]@@ -45,7 +45,7 @@ _number, optional_The threshold in decibels. If the audio is below this threshold, it is considered silent. The default is `-20`. Must be less than `30`.-### `minDuration`+### `minDurationInSeconds`_number, optional_diff --git a/packages/renderer/rust/commands/mod.rs b/packages/renderer/rust/commands/mod.rsindex 1c8830b1e2..f07410f162 100644--- a/packages/renderer/rust/commands/mod.rs+++ b/packages/renderer/rust/commands/mod.rs@@ -53,7 +53,7 @@ pub fn execute_command(opts: CliInputCommandPayload) -> Result<Vec<u8>, ErrorWitCliInputCommandPayload::GetSilences(_command) => {let filter = format!("silencedetect=n={}dB:d={}",- _command.noiseThresholdInDecibels, _command.minDuration+ _command.noiseThresholdInDecibels, _command.minDurationInSeconds);let res = get_silent_parts::get_silent_parts(_command.src, filter.to_string())?;let str = serde_json::to_string(&res)?;diff --git a/packages/renderer/rust/payloads.rs b/packages/renderer/rust/payloads.rsindex 820cdc6e74..580c390195 100644--- a/packages/renderer/rust/payloads.rs+++ b/packages/renderer/rust/payloads.rs@@ -67,7 +67,7 @@ pub mod payloads {pub struct GetSilences {pub src: String,pub noiseThresholdInDecibels: f64,- pub minDuration: f64,+ pub minDurationInSeconds: f64,}#[derive(Serialize, Deserialize, Debug)]diff --git a/packages/renderer/src/compositor/payloads.ts b/packages/renderer/src/compositor/payloads.tsindex 07a5920072..5979f0b6f5 100644--- a/packages/renderer/src/compositor/payloads.ts+++ b/packages/renderer/src/compositor/payloads.ts@@ -76,7 +76,7 @@ export type CompositorCommand = {GetSilences: {src: string;noiseThresholdInDecibels: number;- minDuration: number;+ minDurationInSeconds: number;};Echo: {message: string;diff --git a/packages/renderer/src/get-silent-parts.ts b/packages/renderer/src/get-silent-parts.tsindex 0dd7c70dd4..a11be1cba8 100644--- a/packages/renderer/src/get-silent-parts.ts+++ b/packages/renderer/src/get-silent-parts.ts@@ -12,11 +12,11 @@ import type {LogLevel} from './log-level';export const getSilentParts = async ({src,noiseThresholdInDecibels: passedNoiseThresholdInDecibels,- minDuration: passedMinDuration,+ minDurationInSeconds: passedMinDuration,logLevel,}: {src: string;- minDuration?: number;+ minDurationInSeconds?: number;logLevel?: LogLevel;noiseThresholdInDecibels?: number;}): Promise<GetSilentPartsResponse> => {@@ -26,15 +26,17 @@ export const getSilentParts = async ({false);- const minDuration = passedMinDuration ?? 1;+ const minDurationInSeconds = passedMinDuration ?? 1;- if (typeof minDuration !== 'number') {- throw new Error(`minDuration must be a number, but was ${minDuration}`);+ if (typeof minDurationInSeconds !== 'number') {+ throw new Error(+ `minDurationInSeconds must be a number, but was ${minDurationInSeconds}`+ );}- if (minDuration <= 0) {+ if (minDurationInSeconds <= 0) {throw new Error(- `minDuration must be greater than 0, but was ${minDuration}`+ `minDurationInSeconds must be greater than 0, but was ${minDurationInSeconds}`);}@@ -54,7 +56,7 @@ export const getSilentParts = async ({const res = await compositor.executeCommand('GetSilences', {src,- minDuration,+ minDurationInSeconds,noiseThresholdInDecibels,});diff --git a/packages/renderer/src/test/get-silent-parts.test.ts b/packages/renderer/src/test/get-silent-parts.test.tsindex b2bb36028a..8c6b9a051c 100644--- a/packages/renderer/src/test/get-silent-parts.test.ts+++ b/packages/renderer/src/test/get-silent-parts.test.ts@@ -21,7 +21,7 @@ test('Sensitive settings', async () => {const {silentParts, audibleParts, durationInSeconds} = await getSilentParts({src: exampleVideos.webcam,noiseThresholdInDecibels: 0,- minDuration: 0.1,+ minDurationInSeconds: 0.1,logLevel: 'info',});expect(silentParts.length).toEqual(1);@@ -34,7 +34,7 @@ test('Sensitive settings', async () => {test('Long duration', async () => {const {silentParts, audibleParts} = await getSilentParts({src: exampleVideos.webcam,- minDuration: 10,+ minDurationInSeconds: 10,});expect(silentParts.length).toEqual(0);expect(audibleParts.length).toEqual(1);@@ -47,7 +47,7 @@ test('Wrong file', async () => {try {await getSilentParts({src: exampleVideos.notavideo,- minDuration: 10,+ minDurationInSeconds: 10,});throw new Error('Should not be able to get silent parts from a non-video');} catch (err) {@@ -60,7 +60,7 @@ test('Inexistent file', async () => {try {await getSilentParts({src: exampleVideos.notafile,- minDuration: 10,+ minDurationInSeconds: 10,});throw new Error('Should not be able to get silent parts from a non-video');} catch (err) {@@ -72,7 +72,7 @@ test('folder', async () => {try {await getSilentParts({src: path.dirname(exampleVideos.notafile),- minDuration: 10,+ minDurationInSeconds: 10,});throw new Error('Should not be able to get silent parts from a non-video');} catch (err) {