Class: FFmpeg

core.FFmpeg(options)

An FFmpeg transform stream that provides an interface to FFmpeg.

Constructor

new FFmpeg(options)

Creates a new FFmpeg transform stream
Parameters:
Name Type Description
options Object Options you would pass to a regular Transform stream, plus an `args` option
Properties
Name Type Attributes Default Description
args Array.<string> Arguments to pass to FFmpeg
shell boolean <optional>
false Whether FFmpeg should be spawned inside a shell
Source:
Example
// By default, if you don't specify an input (`-i ...`) prism will assume you're piping a stream into it.
const transcoder = new prism.FFmpeg({
 args: [
   '-analyzeduration', '0',
   '-loglevel', '0',
   '-f', 's16le',
   '-ar', '48000',
   '-ac', '2',
 ]
});
const s16le = mp3File.pipe(transcoder);
const opus = s16le.pipe(new prism.opus.Encoder({ rate: 48000, channels: 2, frameSize: 960 }));

Methods

(static) getInfo(forceopt) → {FFmpegInfo}

Finds a suitable FFmpeg command and obtains the debug information from it.
Parameters:
Name Type Attributes Default Description
force boolean <optional>
false If true, will ignore any cached results and search for the command again
Source:
Throws:
Will throw an error if FFmpeg cannot be found.
Returns:
Type
FFmpegInfo
Example
const ffmpeg = prism.FFmpeg.getInfo();

console.log(`Using FFmpeg version ${ffmpeg.version}`);

if (ffmpeg.output.includes('--enable-libopus')) {
  console.log('libopus is available!');
} else {
  console.log('libopus is unavailable!');
}