Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ffmpeg-on-progress with all npm packages installed. Try it out:

var ffmpegOnProgress = require("ffmpeg-on-progress")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ffmpeg-on-progress v1.0.0

Utility for robustly reporting progress with fluent-ffmpeg.

ffmpeg-on-progress

Utility for robustly reporting ffmpeg command progress with fluent-ffmpeg.

NPM Build Status JavaScript Style Guide

Some ffmpeg commands aren't capable fo producing progress events, such as when the input is a stream or when using multiple inputs. This simple utility allows you to accurately report progress in these cases by looking at the number of frames ffmpeg has processed with the caveat that you need to know the expected output's duration ahead of time.

In cases where fluent-ffmpeg produces a valid progress event, this module is a noop.

Install

npm install --save ffmpeg-on-progress
# or
yarn add ffmpeg-on-progress

Usage

const ffmpeg = require('fluent-ffmpeg')
const ffmpegOnProgress = require('ffmpeg-on-progress')

const logProgress = (progress, event) => {
  // progress is a floating point number from 0 to 1
  console.log('progress', (progress * 100).toFixed())
}

// estimated duration of output in milliseconds
const durationEstimate = 4000

const cmd = ffmpeg('input.avi')
  .output('output.mp4')
  .on('progress', ffmpegOnProgress(logProgress, durationEstimate))
  .run()

Related

License

MIT © Travis Fischer

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free