Back to Remotion

getSilentParts()

packages/docs/docs/renderer/get-silent-parts.mdx

4.0.4612.4 KB
Original Source
<YouTube minutes={2} href="https://www.youtube.com/watch?v=OHrvTMgiXWc" thumb="https://i.ytimg.com/vi/OHrvTMgiXWc/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLC35vhR28KkxA7Bxr5XRqbIsMxe3g" title="Remove silence from videos programmatically" />

getSilentParts()<AvailableFrom v="4.0.18" />

Gets the silent parts of a video or audio in Node.js. Useful for cutting out silence from a video.

Example

ts
import {getSilentParts} from '@remotion/renderer';

const {silentParts, durationInSeconds} = await getSilentParts({
  src: '/Users/john/Documents/bunny.mp4',
  noiseThresholdInDecibels: -20,
  minDurationInSeconds: 1,
});

console.log(silentParts); // [{startInSeconds: 0, endInSeconds: 1.5}]

:::info Pass an absolute path to getSilentParts(). URLs are not supported. :::

Arguments

An object which takes the following properties:

source

string

A local video or audio file path.

noiseThresholdInDecibels?

number

The threshold in decibels. If the audio is below this threshold, it is considered silent. The default is -20. Must be less than 30.

minDurationInSeconds?

number

The minimum duration of a silent part in seconds. The default is 1.

logLevel?

<Options id="log" />

binariesDirectory?<AvailableFrom v="4.0.120" />

<Options id="binaries-directory" />

Return Value

The return value is an object with the following properties:

silentParts

An array of objects with the following properties:

  • startInSeconds: The start time of the silent part in seconds.
  • endInSeconds: The end time of the silent part in seconds.

audibleParts

The inverse of the silentParts array.
An array of objects with the following properties:

  • startInSeconds: The start time of the audible part in seconds.
  • endInSeconds: The end time of the audible part in seconds.

durationInSeconds

The time length of the media in seconds.

Compatibility

<CompatibilityTable chrome={false} firefox={false} safari={false} nodejs={true} bun={true} serverlessFunctions={false} clientSideRendering={false} serverSideRendering={true} player={false} studio={false} />

See also