Giter VIP home page Giter VIP logo

handbrake-js's Introduction

NPM version Build Status Dependency Status Analytics

handbrake-js

Handbrake-js is an alternative, cross-platform distrubution of HandbrakeCLI (v0.9.9) adding Javascript, streaming and improved command-line interfaces.

Command line use

Install

Install Node.js, then run

$ npm install -g handbrake-js

Mac / Linux users may need to run the above with sudo

Usage

Call handbrake as you would HandbrakeCLI, using all the usual options:

$ handbrake --input "Ballroom Bangra.avi" --output "Ballroom Bangra.mp4" --preset Normal

Notifications

During long-running encodes, Mac users can receive system notifications every three minutes displaying current progress. To enable this, ensure terminal-notifier is installed.

Install via homebrew:

$ brew install terminal-notifier

Install via RubyGems:

$ [sudo] gem install terminal-notifier

As a library

Install

$ npm install handbrake-js --save

HandbrakeCLI installation

On Windows and Mac OSX installing handbrake-js automatically installs the correct HandbrakeCLI binary for your platform. Ubuntu users should additionally run:

$ sudo npm -g run-script handbrake-js ubuntu-setup

API Documentation

#handbrake-js

An npm distribution of HandbrakeCLI for command line or library use.

##Methods

###exec

Runs HandbrakeCLI with the supplied options calling the supplied callback on completion. The exec method is best suited for short duration tasks where you can wait until completion for the output.

Params:

  • options Object | Thing | Array

    Options to pass directly to HandbrakeCLI

  • onComplete Function

    If passed, onComplete(err, stdout, stderr) will be called on completion, stdout and stderr being strings containing the HandbrakeCLI output.

####Example

var handbrake = require("handbrake-js");

handbrake.exec({ preset-list: true }, function(err, stdout, stderr){
    if (err) throw err;
    console.log(stdout);
});

###spawn

Spawns a HandbrakeCLI process with the supplied options, returning a handle on the running process.

Returns: HandbrakeProcess - A handle on which you can listen for events on the Handbrake process.

Params:

  • options Object | Thing | Array

    Options to pass directly to HandbrakeCLI

####Example

var handbrake = require("handbrake-js");

var options = {
    input: "Eight Miles High.mov",
    output: "Eight Miles High.m4v",
    preset: "Normal"
};

handbrake.spawn(options)
    .on("error", function(err){
        console.log("ERROR: " + err.message);
    })
    .on("output", console.log);
    .on("progress", function(progress){
        console.log(progress.task + ": " + progress.percentComplete);
    })
    .on("complete", function(){ 
        console.log("Done!"); 
    });

#HandbrakeProcess

A handle on the Handbrake encoding process, used to catch and respond to run-time events.

##Events

###progress

Fired at regular intervals passing progress information

Params:

  • progress Object
    • percentComplete Number - Percentage complete
    • fps Number - Frames per second
    • avgFps Number - Average frames per second
    • eta String - Estimated time until completion
    • task String - Task description, e.g. "Encoding", "Scanning" etc.

###output

Passes the standard HandbrakeCLI output

Params:

  • output String

###terminated

Fired if Handbrake-js was killed by CTRL-C

###error

Fired if either HandbrakeCLI crashed or ran successfully but failed to find a valid title in the input video.

Params:

  • error Error

###complete

Fired on completion of a successful encode

#HandbrakeOptions

An options Thing describing all valid Handbrake option names, types and values.

NPM

handbrake-js's People

Contributors

75lb avatar dudemullet avatar

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.