npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ffmpeg-simplified

v2.1.1

Published

A wrapper around ffmpeg to achieve tasks via simple APIs.

Readme

ffmpeg-simplified

wakatime Node.js CI GitHub License GitHub Release codecov typescript Size bun

ffmpeg-simplified is a batteries-included toolkit that provides a simple, ergonomic Promise-based API for everyday audio and video automation tasks. It directly wraps your locally installed ffmpeg binary without any intermediate dependencies.

Features

  • Zero external wrapper dependencies - Direct FFmpeg integration with no third-party wrappers to maintain
  • Zero-configuration - Automatic detection of system-installed ffmpeg and ffprobe binaries
  • Comprehensive workflows - Noise reduction, slicing, merging, frame capture, audio swapping, audio syncing and more
  • TypeScript-native - Rich type definitions and detailed JSDoc comments for every function
  • Modern runtimes - Ships prebuilt bundles via tsdown targeting Node ≥22 and Bun ≥1.0
  • Battle-tested - Test suite powered by bun test with real media fixtures

Requirements

  • Node.js ≥ 22.0.0 or Bun ≥ 1.0
  • A working ffmpeg installation available on your PATH

The package automatically detects system-installed ffmpeg and ffprobe binaries using the which utility. We intentionally avoid bundling ffmpeg-static so you can manage codecs and updates yourself.

Custom FFmpeg Wrapper

The library includes a lightweight custom wrapper (src/vendor/ffmpeg.ts) tailored specifically for this package's use cases:

  • Direct process spawning - No argument parsing issues with complex filter chains
  • Progress tracking - Parses FFmpeg's stderr for real-time progress events
  • Stream support - Handles Node.js ReadStream/WriteStream for piped I/O
  • FFprobe integration - Built-in JSON parsing of media metadata
  • Error handling - Robust stderr capture and error reporting
  • Version detection - Automatically detects FFmpeg installation and version

This approach eliminates dependency on external wrappers while providing a clean, maintainable implementation focused on our specific needs.

Installation

Install with your preferred package manager:

bun add ffmpeg-simplified
# or
npm install ffmpeg-simplified
# or
yarn add ffmpeg-simplified

Quick start

import {
  delayAudio,
  detectSilences,
  formatMedia,
  getFrames,
  getMediaDuration,
  getVideoDimensions,
  mergeSlices,
  replaceAudio,
  slice,
  sliceAndMerge,
  splitFileOnSilences,
  type Logger,
} from "ffmpeg-simplified";

const duration = await getMediaDuration("./samples/interview.mp4");
const silences = await detectSilences("./samples/interview.wav", {
  silenceThreshold: -45,
  silenceDuration: 0.3,
});
await formatMedia("./samples/interview.wav", "./output/clean.wav", {
  fast: true,
  noiseReduction: { dialogueEnhance: true },
});
await delayAudio("./samples/video.mp4", "./output/synced.mp4", 0.5);

Custom logging

Most functions accept an optional logger parameter that conforms to the Logger interface (compatible with console and popular logging libraries):

import type { Logger } from "ffmpeg-simplified";

// Use the built-in console
await formatMedia(input, output, options, callbacks, console);

// Or your own logger (pino, winston, etc.)
import pino from "pino";
const logger = pino();
await sliceAndMerge(input, output, options, logger);

// Minimal custom logger
const customLogger: Logger = {
  info: (msg) => console.log(`[INFO] ${msg}`),
  error: (msg) => console.error(`[ERROR] ${msg}`),
};
await splitFileOnSilences(file, outputDir, options, callbacks, customLogger);

The Logger interface is simple and all methods are optional:

interface Logger {
  info?: (message: string, ...args: any[]) => void;
  debug?: (message: string, ...args: any[]) => void;
  warn?: (message: string, ...args: any[]) => void;
  error?: (message: string, ...args: any[]) => void;
}

API overview

delayAudio(inputFile, outputFile, delayInSeconds, logger?)

Adjusts audio synchronization in a video by applying a delay (positive) or advance (negative) to the audio track.

detectSilences(filePath, options)

Finds quiet sections in an audio file using silencedetect.

formatMedia(input, outputPath, options?, callbacks?, logger?)

Preprocess audio streams (noise reduction, mono downmixing, fast mode, callback hooks).

getMediaDuration(filePath) / getVideoDimensions(filePath)

Lightweight wrappers around ffprobe for duration and resolution metadata.

splitFileOnSilences(filePath, outputDir, options?, callbacks?, logger?)

Chunk long-form audio into natural speaking segments and normalizes short clips.

slice(filePath, options, logger?) / sliceAndMerge(filePath, outputFile, options, logger?)

Slice videos by absolute timestamps or human-friendly timecodes, then optionally merge back together.

mergeSlices(inputFiles, outputFile, options?, logger?)

Concat arbitrary files using the efficient concat demuxer.

replaceAudio(videoFile, audioFile, outputFile, logger?)

Swap a video's audio track without re-encoding the video stream.

getFrames(videoFile, options, logger?)

Extract thumbnails at a fixed cadence with optional cropping and preprocessing presets.

Refer to the inline JSDoc comments for parameter details and return types—every exported function documents accepted options and callback hooks.

Development

Install dependencies and run the toolchain with Bun:

bun install
bun run build
bun test
  • Builds are handled by tsdown, producing ESM output and declaration files in dist/.
  • Tests rely on Bun's native test runner and preload setupTests.ts to expose fixture paths (testing/sample.*). The suite exercises real audio/video transformations, so ensure ffmpeg and ffprobe binaries are reachable.

Contributing

  1. Fork the repo and create a feature branch.
  2. Install dependencies with bun install.
  3. Run bun test and bun run build before submitting a pull request.

License

MIT © Ragaeeb Haq