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 🙏

© 2024 – Pkg Stats / Ryan Hefner

easier-ffmpeg

v1.0.1

Published

A simple and intuitive Node.js wrapper for ffmpeg, making it easy to perform video and audio processing tasks.

Downloads

2

Readme

EasierFFmpeg

A simple and intuitive Node.js wrapper for ffmpeg, making it easy to perform video and audio processing tasks.

Installation

npm i easier-ffmpeg

Usage

import { Ffmpeg } from 'easier-ffmpeg';

// Create an Ffmpeg instance
const ffmpeg = new Ffmpeg();

// Basic conversion
ffmpeg.input('input.avi')
  .videoCodec('libx264')
  .audioCodec('aac')
  .output('output.mp4')
  .overwrite() // Overwrite output file if it exists
  .logLevel('info')
  .run()
  .then(() => console.log('Conversion complete!'))
  .catch(error => console.error('Conversion failed:', error));

// Concatenate videos (scaling and padding to match largest dimensions)
const inputFiles = ['video1.mp4', 'video2.avi', 'video3.mov'];
const outputFile = 'concatenated_video.mp4';

ffmpeg.concatVideos(inputFiles, outputFile)
  .then(() => console.log('Concatenation complete!'))
  .catch(error => console.error('Concatenation failed:', error));

// More examples...

Methods

  • input(file: string): Sets the input file.
  • output(file: string): Sets the output file.
  • videoCodec(codec: string): Sets the video codec.
  • videoBitrate(bitrate: string): Sets the video bitrate.
  • videoFps(fps: number): Sets the video frames per second.
  • videoFpsMax(fpsMax: number): Sets the maximum video frames per second.
  • videoSize(size: string): Sets the video size (e.g., '1280x720').
  • videoAspect(aspect: string): Sets the video aspect ratio (e.g., '16:9').
  • videoCrop(crop: 'none' | 'all' | 'codec' | 'container'): Applies cropping based on metadata.
  • videoTune(tune: string): Sets the video tuning algorithm (e.g., 'film', 'animation').
  • videoPreset(preset: string): Sets the video encoding preset (e.g., 'ultrafast', 'medium').
  • videoPass(pass: number): Specifies the pass number for two-pass encoding.
  • videoPasslogfile(passlogfile: string): Sets the prefix for the two-pass log file.
  • audioCodec(codec: string): Sets the audio codec.
  • audioBitrate(bitrate: string): Sets the audio bitrate.
  • audioSampleRate(sampleRate: number): Sets the audio sample rate.
  • audioChannels(channels: number): Sets the number of audio channels.
  • subtitleCodec(codec: string): Sets the subtitle codec.
  • complexFilter(options: ComplexFilterOptions): Adds a complex filtergraph.
  • overwrite(overwrite = true): Sets whether to overwrite the output file if it exists.
  • logLevel(level: 'quiet' | 'panic' | 'fatal' | 'error' | 'warning' | 'info' | 'verbose' | 'debug' | 'trace'): Sets the logging level.
  • duration(duration: string): Sets the duration of the output media.
  • seek(seek: string): Starts encoding from a specific time position.
  • format(format: string): Forces the output format.
  • addMetadata(metadata: Record<string, string>): Adds metadata key-value pairs to the output file.
  • addMap(map: string): Manually controls stream selection.
  • addArgument(args: string[]): Allows the user to pass an arbitrary argument array e.g. Array("-vsync", "-1")
  • concatVideos(inputFiles: string[], outputFile: string): Concatenates videos, scaling and padding them to the same dimensions. Be careful, running this will call "run" internally.
  • run(): Executes the ffmpeg command with the configured options. Returns a promise.

Interfaces

  • VideoOptions: Options for video encoding.
  • AudioOptions: Options for audio encoding.
  • SubtitleOptions: Options for subtitles.
  • ComplexFilterOptions: Options for complex filtergraphs.
  • FfmpegOptions: General ffmpeg options.

Notes

This wrapper currently exposes a subset of ffmpeg's functionality. More options and methods will be added in the future. Feel free to make your own pull requests. Refer to the ffmpeg documentation for more details about the available options and their usage: https://ffmpeg.org/ffmpeg.html

License

ISC