Code Monkey home page Code Monkey logo

ffbinaries-node's Introduction

ffbinaries downloader

NPM Version NPM Downloads Build status Coveralls coverage

Downloads precompiled ffmpeg, ffprobe, ffplay and ffserver binaries from ffbinaries.com.

This module is cross-platform and can be used through CLI or as a Node module, (either as a build step or in a postinstall script).

You can download whatever binaries you need during the build if you'd like to bundle the binaries with your distributable files or just download it on user's machine during initial setup process.

Change log

Version 1.0.8

  • Added force mode to downloadBinaries method
  • Returning full version of components in locateBinariesSync method

Version 1.0.7

  • Looking for correct filename in locateBinariesSync on Windows
  • Fault tolerance + more precise conditions in locateBinariesSync

Version 1.0.6

  • Added locateBinariesSync method to look for binaries and check their version
  • Changed HTTP to HTTPS in links in readme

Version 1.0.5

  • Updated dependencies
  • Switched API endpoints to HTTPS protocol
  • Fixed detection of binaries already existing in destination directory
  • Added clean up phase after tests

Version 1.0.4

  • Fixed clearCache method to empty the cache directory instead of removing it (it used to cause a ENOENT error when executed before downloading binaries)

Version 1.0.3

  • Preventing storage of incomplete archives in cache
  • Added status codes in downloadBinaries method result

Version 1.0.2

  • Improved support for incomplete arguments in downloadBinaries
  • Added getBinaryFilename(component, platform)

Version 1.0.1

  • Added linter to ensure consistent code
  • Added Coveralls integration
  • Increased unit test coverage

Version 1.0.0

  • Updated syntax
  • Added unit tests
  • Improved error handling
  • Various small fixes

Reporting issues

If you're experiencing issues please update to the newest version and run ffbinaries clearcache.

If that doesn't resolve it simply raise an issue on GitHub.

Make sure to include the information about which version you're using, platform, the exact commands you're trying to execute and the output.

New syntax

New syntax got introduced in 1.0.0.

With the new syntax binaries to download are specified first (i.e. ffmpeg or ffplay). Platform is now a flag.

This change applies to both command line interface and programmatical usage.

You can see the old syntax documented in v0.1.8.

Usage

You can run it from your code or through CLI.

If output argument is specified the binary will be placed there. It will default to current working directory.

If platform argument is missing then the current platform will be automatically detected and binaries for it will be downloaded.

If components argument is missing then binaries of all available components will be downloaded (see Included components section).

CLI

When installed globally with npm i ffbinaries -g this module will register itself on command line interface.

Arguments

CLI uses the following syntax:

ffbinaries [components] [--platform] [--output] [--quiet] [--version]

Each flag can also be abbreviated in your scripts with -p, -o, -q and -v respectively.

Examples

Download all binaries for your platform

ffbinaries

Download all binaries for a specified platform

ffbinaries -p=mac

Download only ffplay for 64-bit Windows, quiet output

ffbinaries ffplay -p=win-64 --quiet

Download only ffmpeg and ffprobe, version 3.2 for 64-bit Linux, quiet output, save binaries in a specified directory

ffbinaries ffmpeg ffprobe -p=linux-64 -q -v=3.2 --output=/usr/local/bin

Additional commands

There are also ffbinaries help, ffbinaries versions and ffbinaries clearcache.

Programmatically

Methods

ffbinaries library exports the following methods:

  • downloadBinaries(platform, opts, callback) downloads and extracts the requested binaries.

    The opts parameter is an object that can contain these optional parameters:

    • destination: the path where the binaries will be downloaded to. If not provided it will default to ..
    • components: an array of string values that describes which components to download. If not provided it will default to all components available for the platform.
    • version: version of ffmpeg to download
    • force: ignore check for existing binaries in the destination and overwrite them if necessary
    • quiet: suppress verbose logs
  • getVersionData(version, callback) fetches the full data set without downloading any binaries.

  • listVersions(callback) returns the list of available versions from the API

  • listPlatforms() returns the list of available platforms

  • detectPlatform() returns the platform code of the machine as detected by the module.

  • resolvePlatform(input) resolves input to a platform code (matches aliases).

  • getBinaryFilename(component, platform) resolves a filename of a binary for a given platform (appends ".exe" in Windows).

  • locateBinariesSync(components, opts) looks for binaries already existing in the system. Returns object with located binaries, their paths and versions.

    opts parameter is an object that can specify these additional options:

    • paths to provide locations to check in first
    • ensureExecutable will set executable flag on the file if it's missing
  • clearCache() purges local cache

Examples

Download all binaries for your platform

var ffbinaries = require('ffbinaries');

ffbinaries.downloadBinaries(function () {
  console.log('Downloaded all binaries for current platform.');
});

Download only ffmpeg and ffprobe, version 3.2 for 64-bit Linux, quiet output, save binaries in a specified location

var ffbinaries = require('ffbinaries');
var dest = __dirname + '/binaries';

ffbinaries.downloadBinaries(['ffmpeg', 'ffprobe'], {platform: 'linux-64', quiet: true, destination: dest}, function () {
  console.log('Downloaded ffplay and ffprobe binaries for linux-64 to ' + dest + '.');
});

See more examples.

Platforms

The following platform codes are available:

windows-32 (aliases: win, windows, win-32), windows-64 (alias: win-64)

linux-32 (alias: linux), linux-64, linux-armhf (alias: linux-arm), linux-armel

osx-64 (aliases: mac, osx, mac-64)

You can use aliases as your platform code argument in both CLI and programmatically.

Included components

Mac Linux Windows
ffmpeg v v v
ffprobe v v v
ffserver v v
ffplay v v* v

(* Only linux-32 and linux-64 builds of ffplay 3.2 are currently available)

Source of binaries

The API providing data to the module is located at ffbinaries.com. The code is located in ffbinaries-api repo.

The binaries are hosted on GitHub as releases of ffbinaries-prebuilt repo.

Contributing

If you'd like to contribute to this project have a look at contributing.md file for more information (including basic guidelines and a list of TODOs).

ffbinaries-node's People

Contributors

agmcleod avatar aredfox avatar jeongukjae avatar kevingodell avatar vot avatar zeevl avatar

Watchers

 avatar  avatar

Forkers

sanram

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.