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

videohandler

v1.1.2

Published

FFmpeg-based video manipulation library for Node.js

Readme

VideoHandler

A powerful, easy-to-use FFmpeg wrapper for Node.js that provides common video manipulation operations.

Prerequisites

FFmpeg must be installed on your system:

macOS:

brew install ffmpeg

Ubuntu/Debian:

sudo apt update
sudo apt install ffmpeg

Docker:

RUN wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
    tar xvf ffmpeg-release-amd64-static.tar.xz && \
    mv ffmpeg-*-amd64-static/ffmpeg /usr/local/bin/ && \
    mv ffmpeg-*-amd64-static/ffprobe /usr/local/bin/ && \
    rm -rf ffmpeg-release-amd64-static.tar.xz ffmpeg-*-amd64-static

Installation

npm install videohandler

Usage

import videoHandler from 'videohandler';

// Or import the class for custom instances
import { VideoHandler } from 'videohandler';

API

trimVideo(inputPath, outputPath, startTime, duration)

Trim/cut a video to a specific duration.

await videoHandler.trimVideo(
    'input.mp4',
    'output.mp4',
    10,  // start at 10 seconds
    30   // duration of 30 seconds
);

convertFormat(inputPath, outputPath, format)

Convert video to different format.

await videoHandler.convertFormat('input.avi', 'output.mp4', 'mp4');

compressVideo(inputPath, outputPath, options)

Compress video with custom quality settings.

await videoHandler.compressVideo('input.mp4', 'output.mp4', {
    crf: 28,           // Quality: 0-51 (lower = better quality)
    preset: 'medium',  // Speed: ultrafast, fast, medium, slow, veryslow
    bitrate: '1000k'   // Optional: set specific bitrate
});

extractAudio(inputPath, outputPath)

Extract audio track from video.

await videoHandler.extractAudio('video.mp4', 'audio.mp3');

addWatermark(videoPath, watermarkPath, outputPath, position)

Add image watermark to video.

await videoHandler.addWatermark(
    'video.mp4',
    'logo.png',
    'output.mp4',
    'bottom-right'  // top-left, top-right, bottom-left, bottom-right
);

getMetadata(inputPath)

Get video metadata (duration, codec, resolution, etc.).

const metadata = await videoHandler.getMetadata('video.mp4');
console.log(metadata);

generateThumbnail(inputPath, outputPath, timestamp)

Generate thumbnail from video at specific time.

await videoHandler.generateThumbnail('video.mp4', 'thumb.png', 5);

resizeVideo(inputPath, outputPath, size)

Resize video to specific dimensions.

await videoHandler.resizeVideo('input.mp4', 'output.mp4', '1280x720');

mergeVideos(inputPaths, outputPath)

Concatenate multiple videos into one.

await videoHandler.mergeVideos(
    ['video1.mp4', 'video2.mp4', 'video3.mp4'],
    'merged.mp4'
);

extractFrames(inputPath, outputDir, fps)

Extract frames from video.

await videoHandler.extractFrames('video.mp4', './frames', 1);
// Extracts 1 frame per second

addAudioToVideo(videoPath, audioPath, outputPath)

Replace or add audio track to video.

await videoHandler.addAudioToVideo('video.mp4', 'audio.mp3', 'output.mp4');

Custom Instance

If you need to specify custom FFmpeg paths:

import { VideoHandler } from 'videohandler';

const customHandler = new VideoHandler({
    ffmpegPath: '/custom/path/to/ffmpeg',
    ffprobePath: '/custom/path/to/ffprobe'
});

await customHandler.trimVideo('input.mp4', 'output.mp4', 0, 10);

Error Handling

All methods return Promises and should be used with try/catch:

try {
    await videoHandler.trimVideo('input.mp4', 'output.mp4', 0, 10);
    console.log('Video processed successfully!');
} catch (error) {
    console.error('Error processing video:', error);
}

License

ISC

Author

Rupendra Vadlamudi