ffmpeg-static vs @ffmpeg/ffmpeg vs fluent-ffmpeg
FFmpeg Libraries for Node.js
ffmpeg-static@ffmpeg/ffmpegfluent-ffmpegSimilar Packages:

FFmpeg Libraries for Node.js

FFmpeg Libraries for Node.js are tools that allow developers to integrate FFmpeg (a powerful multimedia framework) functionality into their Node.js applications. These libraries provide APIs to perform various audio and video processing tasks, such as encoding, decoding, transcoding, streaming, filtering, and manipulating multimedia files programmatically. They enable developers to leverage FFmpeg's capabilities directly from their JavaScript or TypeScript code, making it easier to build applications that handle multimedia content, such as video editors, converters, or streaming platforms.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
ffmpeg-static392,5831,32448.2 kB324 months agoGPL-3.0-or-later
@ffmpeg/ffmpeg313,94417,21872 kB413a year agoMIT
fluent-ffmpeg08,25412.4 MB4192 years agoMIT

Feature Comparison: ffmpeg-static vs @ffmpeg/ffmpeg vs fluent-ffmpeg

FFmpeg Binary Inclusion

  • ffmpeg-static:

    ffmpeg-static provides a pre-built FFmpeg binary that is included in the package. This makes it easy to use FFmpeg in your Node.js applications without having to install it separately on the system.

  • @ffmpeg/ffmpeg:

    @ffmpeg/ffmpeg does not include the FFmpeg binary. Instead, it provides a JavaScript implementation of FFmpeg that runs in the browser and Node.js, allowing for multimedia processing without relying on external binaries.

  • fluent-ffmpeg:

    fluent-ffmpeg does not include the FFmpeg binary by default. It requires you to have FFmpeg installed on your system or provide the path to the FFmpeg executable. This allows for greater flexibility but requires an external installation.

Ease of Use

  • ffmpeg-static:

    ffmpeg-static is very easy to use, as it provides a straightforward way to access the FFmpeg binary without any configuration. It is ideal for quick implementations.

  • @ffmpeg/ffmpeg:

    @ffmpeg/ffmpeg offers a simple API for using FFmpeg features, but it may require some learning to understand its JavaScript-based approach, especially for complex tasks.

  • fluent-ffmpeg:

    fluent-ffmpeg provides a highly intuitive and chainable API for working with FFmpeg, making it easy to construct complex command sequences. It is designed for developers who want to leverage FFmpeg's full capabilities without dealing with low-level command-line syntax.

Streaming Support

  • ffmpeg-static:

    ffmpeg-static itself does not handle streaming, but it provides access to the FFmpeg binary, which supports streaming. You would need to implement streaming logic in your application while using the binary.

  • @ffmpeg/ffmpeg:

    @ffmpeg/ffmpeg supports streaming input and output, allowing for real-time processing of audio and video data. This is useful for applications that require low-latency processing or handling large files without loading them entirely into memory.

  • fluent-ffmpeg:

    fluent-ffmpeg has excellent support for streaming, allowing you to pipe data between streams and handle real-time processing. It provides features for working with streams, making it suitable for applications that require efficient data handling.

Code Example

  • ffmpeg-static:

    Example of using ffmpeg-static to access the FFmpeg binary:

    const ffmpegPath = require('ffmpeg-static');
    const { execFile } = require('child_process');
    
    execFile(ffmpegPath, ['-version'], (err, stdout, stderr) => {
      if (err) throw err;
      console.log(stdout);
    });
    
  • @ffmpeg/ffmpeg:

    Example of using @ffmpeg/ffmpeg to transcode a video in the browser:

    import { createFFmpeg, fetchFile } from '@ffmpeg/ffmpeg';
    const ffmpeg = createFFmpeg({ log: true });
    
    (async () => {
      await ffmpeg.load();
      ffmpeg.FS('writeFile', 'input.mp4', await fetchFile('input.mp4'));
      await ffmpeg.run('-i', 'input.mp4', 'output.mp4');
      const data = ffmpeg.FS('readFile', 'output.mp4');
    
      const video = document.createElement('video');
      video.src = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));
      document.body.appendChild(video);
      video.play();
    })();
    
  • fluent-ffmpeg:

    Example of using fluent-ffmpeg to transcode a video:

    const ffmpeg = require('fluent-ffmpeg');
    const inputFile = 'input.mp4';
    const outputFile = 'output.mp4';
    
    ffmpeg(inputFile)
      .output(outputFile)
      .on('end', () => console.log('Transcoding finished!'))
      .on('error', (err) => console.error('Error:', err))
      .run();
    

How to Choose: ffmpeg-static vs @ffmpeg/ffmpeg vs fluent-ffmpeg

  • ffmpeg-static:

    Choose ffmpeg-static if you want a simple way to include a pre-built FFmpeg binary in your Node.js application. It is lightweight and easy to use, making it perfect for projects that need FFmpeg functionality without the hassle of installation.

  • @ffmpeg/ffmpeg:

    Choose @ffmpeg/ffmpeg if you need a pure JavaScript implementation of FFmpeg that runs in the browser or Node.js. It is ideal for projects that require a self-contained solution without external dependencies.

  • fluent-ffmpeg:

    Choose fluent-ffmpeg if you need a comprehensive and user-friendly API for working with FFmpeg in Node.js. It is suitable for projects that require advanced features, chaining commands, and better handling of input/output streams.

README for ffmpeg-static

ffmpeg-static

Static ffmpeg binaries for macOS, Linux, Windows.

Supports macOS (64-bit and arm64), Linux (32 and 64-bit, armhf, arm64), Windows (32 and 64-bit). The ffmpeg version currently used is 6.1.1.

npm version minimum Node.js version

Note: The version of ffmpeg-static follows SemVer. When releasing new versions, we do not consider breaking changes in ffmpeg itself, but only the JS interface (see below). For example, ffmpeg-static@4.5.0 might download ffmpeg 5.0. To prevent an ffmpeg-static upgrade downloading backwards-incompatible ffmpeg versions, use a strict version range for it or use a lockfile.

Also check out node-ffmpeg-installer!

Installation

$ npm install ffmpeg-static

Note: During installation, it will download the appropriate ffmpeg binary from the b6.1.1 GitHub release. Use and distribution of the binary releases of ffmpeg are covered by their respective license.

Custom binaries url

By default, the ffmpeg binary will get downloaded from https://github.com/eugeneware/ffmpeg-static/releases/download. To customise this, e.g. when using a mirror, set the FFMPEG_BINARIES_URL environment variable.

export FFMPEG_BINARIES_URL=https://cdn.npmmirror.com/binaries/ffmpeg-static
npm install ffmpeg-static

Electron & other cross-platform packaging tools

Because ffmpeg-static will download a binary specific to the OS/platform, you need to purge node_modules before (re-)packaging your app for a different OS/platform (read more in #35).

Example Usage

Returns the path of a statically linked ffmpeg binary on the local filesystem.

const pathToFfmpeg = require('ffmpeg-static')
console.log(pathToFfmpeg)
// /Users/j/playground/node_modules/ffmpeg-static/ffmpeg

Check the example script for a more thorough example.

Sources of the binaries

The binaries downloaded by ffmpeg-static are from these locations:

Show your support

This npm package includes statically linked binaries that are produced by the following individuals. Please consider supporting and donating to them who have been providing quality binary builds for many years: