Skip to content

Latest commit

 

History

History
77 lines (52 loc) · 1.19 KB

README.md

File metadata and controls

77 lines (52 loc) · 1.19 KB

ffmpeg-node

Simple TypeScript wrapper for FFmpeg CLI commands including the ability to stop the recording

Installation

npm install --save @unaxiom/ffmpeg

Needs to have ffmpeg installed and available in PATH

API

  • Import the module
import * as FFmpeg from '@unaxiom/ffmpeg';

Or require the module

var FFmpeg = require("./ffmpeg");
  • Create the object
var ffmpeg = new FFmpeg.FFmpeg();
  • Add an individual option
ffmpeg.addOption("-y");
  • Add an array of options
ffmpeg.addOptions([
        "-y",
        "-i", "screen.vb8.webm",
        "-vf", "setpts=80*PTS",
    ]);
  • Set the output file name
ffmpeg.setOutputFile("output.webm");
  • Set up a callback function when the process completes/quits
ffmpeg.setOnCloseCallback(function (code: number, signal: string) {
        console.log("Process quit from setOnCloseCallback with code -> " + code + " and signal -> " + signal);
    });
  • Run the process
ffmpeg.run(); // Accepts an optional boolean that supresses the standard output. Default is false.
  • Quit the process (graceful quit)
ffmpeg.quit();
  • Kill the process
ffmpeg.kill();