ffmpeg-on-progress-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ffmpeg-on-progress

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

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-ts
# or
yarn add ffmpeg-on-progress-ts

Usage

import ffmpeg from 'fluent-ffmpeg'
import ffmpegOnProgress from 'ffmpeg-on-progress-ts'
import type { ProgressFunction } from 'ffmpeg-on-progress-ts'

const logProgress: ProgressFunction = (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

Package Sidebar

Install

npm i ffmpeg-on-progress-ts

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

4.57 kB

Total Files

7

Last publish

Collaborators

  • heroclay