Skip to main content

getSilentParts()

Also available as a 2min video
Remove silence from videos programmatically

getSilentParts()v4.0.18

note

This function is meant to be used in Node.js applications. It cannot run in the browser.

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

Example

silent-parts.mjs
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}]
silent-parts.mjs
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, 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.

minDurationInSeconds

number, optional

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

logLevel?

One of verbose, info, warn, error.
Determines how much is being logged to the console.
verbose will also log console.log's from the browser.
Default info.

binariesDirectory?v4.0.120

The directory where the platform-specific binaries and libraries that Remotion needs are located. Those include an ffmpeg and ffprobe binary, a Rust binary for various tasks, and various shared libraries. If the value is set to null, which is the default, then the path of a platform-specific package located at node_modules/@remotion/compositor-* is selected.
This option is useful in environments where Remotion is not officially supported to run like bundled serverless functions or Electron.

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.

See also