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

ffmpeg-progress-wrapper

v2.0.1

Published

A simple wrapper that helps with determinng the progress of the ffmpeg conversion

Downloads

630

Readme

FFMPEG Progress Wrapper

Wraps your ffmpeg raw command line with a nice progress interface


Installation

$ npm install ffmpeg-progress-wrapper $ yarn ffmpeg-progress-wrapper

Use cases

  • Provides a progress status for your video without you having to guess the frame count
  • Provides duration and bitrate of the file

Usage

Constructor

import {FFMpegProgress} from 'ffmpeg-progress-wrapper';
new FFMpegProgress(args, options);
  • args: string[] - List of string arguments
  • options?: object - optional
    • cmd?: string - path to ffmpeg (defaults to ffmpeg from PATH)
    • cwd?: string - working dir (defaults to current working dir)
    • env?: ProcessEnv - environment vars (defaults to process.env)
    • duration?: number - output duration in seconds (default is determined from file)
      useful when using complex filters and the input time differs from output
    • hideFFConfig?: boolean - hide ffmpeg config from stderr (default false)
    • maxMemory?: number - max amount of bytes allowed by the process to use before killing for OOM (default unset)

FFMpegProgress.on('progress')

  • progressData: object
    • eta: number | null - time left to process in seconds
    • speed: number | null - processed output time / real time (2x - twice realtime, 0.5x - half realtime)
    • fps: number | null
    • time: number | null - current output time in seconds
    • frame: number | null - current output frame
    • progress: number | null - progress percentage (from 0 to 1)
    • drop: number - dropped frames
    • dup: number - duplicated frames
    • quality: number[][] - stream quality per frame, per stream
    • psnr: { y: number | null, u: number | null, v: number | null, all: number | null }[][] - stream psnr per file, per stream, per channel (enabled via -psnr ffmpeg arg)
    • size: number | null - output file size
    • bitrate: number | null - output file bitrate in bytes

FFMpegProgress.on('raw') - Fires whenever ffmpeg outputs text - very volatile

  • raw: string

FFMpegProgress.on('details') - Fires once per command, at the beginning

  • details: object
    • duration: number - video duration in seconds
    • bitrate: number - video bitrate in bytes
    • start: number - video's first frame time in seconds

Example

const {FFMpegProgress} = require('ffmpeg-progress-wrapper');
// or
import {FFMpegProgress} from 'ffmpeg-progress-wrapper';

(async () => {
  
    const process = new FFMpegProgress(['-i', 'test.mov' ,'test output.mp4']);
    
    process.on('raw', console.log);
    
    process.once('details', (details) => console.log(JSON.stringify(details));
    
    process.on('progress', (progress) => console.log(JSON.stringify(progress));
    
    process.once('end', console.log.bind(console, 'Conversion finished and exited with code'));
    
    process.done(console.log);
    
    await process.onDone();

})();
/**
{
  duration: 216,
  bitrate: 36864,
  start: 0,
  resolution: { width: 320, height: 240 },
  fps: 25
}
{
  drop: 0,
  dup: 0,
  frame: 1366,
  time: 52.480078,
  speed: 105,
  fps: 0,
  eta: 1.5573325904761905,
  progress: 0.24296332407407406,
  quality: [ [ 28 ] ],
  psnr: [ [ { y: NaN, u: NaN, v: NaN, all: NaN } ] ],
  size: 36,
  bitrate: 0
}
{
  drop: 0,
  dup: 0,
  frame: 2700,
  time: 105.840078,
  speed: 106,
  fps: 2696.44,
  eta: 1.0392445471698113,
  progress: 0.4900003611111111,
  quality: [ [ 28 ] ],
  psnr: [ [ { y: NaN, u: NaN, v: NaN, all: NaN } ] ],
  size: 262180,
  bitrate: 20275.2
}
{
  drop: 0,
  dup: 0,
  frame: 4138,
  time: 163.360078,
  speed: 109,
  fps: 2756.01,
  eta: 0.4829350642201836,
  progress: 0.7562966574074074,
  quality: [ [ 28 ] ],
  psnr: [ [ { y: NaN, u: NaN, v: NaN, all: NaN } ] ],
  size: 524324,
  bitrate: 26316.8
}
{
  drop: 0,
  dup: 0,
  frame: 5423,
  time: 216.800078,
  speed: 110,
  fps: 2747.61,
  eta: 0,
  progress: 1.0037040648148148,
  quality: [ [ -1 ] ],
  psnr: [ [ { y: Infinity, u: Infinity, v: Infinity, all: Infinity } ] ],
  size: 977469,
  bitrate: 36966.4
}
Conversion finished and exited with code 0 null
*/