Package Exports
- handbrake-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (handbrake-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
#handbrake-js Handbrake-js is Handbrake for node.js, funnily enough. It aspires to provide a lean and stable foundation for building video transcoding software.
Compatible Platforms
Tested on Mac OSX, Ubuntu 14, Windows XP, Windows 8.1.
Ubuntu 14.04 notice: Transcoding to MP4 fails on Ubuntu since 14.04 for this reason.
##Installation ###System Requirements Just node.js. Every else is installed automatically.
###As a library Move into your project directory then run:
$ npm install handbrake-js --save
Mac / Linux users may need to run with sudo
.
Now you can begin encoding from your app.
var hbjs = require("handbrake-js");
hbjs.spawn({ input: "dope shit.avi", output: "dope shit.m4v" })
.on("error", function(err){
// invalid user input, no video found etc
})
.on("progress", function(progress){
console.log(
"Percent complete: %s, ETA: %s",
progress.percentComplete,
progress.eta
);
});
###As a command-line app From any directory run the following:
$ npm install -g handbrake-js
Mac / Linux users may need to run with sudo
.
Now, you can call handbrake
as you would HandbrakeCLI, using all the usual options. By default, just statistics are output, passing --verbose
prints the raw HandbrakeCLI output. This command will transcode an AVI to the more universal H.264 (mp4):
$ handbrake --input "some episode.avi" --output "some episode.mp4" --preset Normal
Task % done FPS Avg FPS ETA
Encoding 1.07 131.76 158.12 00h21m11s
#API Documentation Handbrake for node.js.
###hbjs.spawn(options, [mocks])
Spawns a HandbrakeCLI process with the supplied options, returning an instance of Handbrake
on which you can listen for events.
- options
Object | Array
Options to pass directly to HandbrakeCLI - mocks
Object
Optional mock objects, for testing
Returns: A Handbrake
instance on which you can listen for events.
####Examples
var handbrakeJs = require("handbrake-js");
handbrakeJs.spawn(options)
.on("error", console.error)
.on("output", console.log);
##class: Handbrake A thin wrapper on the handbrakeCLI child_process handle
Extends: EventEmitter
###handbrake.output
A String
containing all handbrakeCLI output
###handbrake.options
the options HandbrakeCLI was spawned with
###event: "start" Fired as HandbrakeCLI is launched. Nothing has happened yet.
###event: "begin" Fired when encoding begins. If you're expecting an encode and this never fired, something went wrong.
###event: "progress"
Fired at regular intervals passing a progress
object containing:
- taskNumber
Number
current task index - taskCount
Number
total tasks in the queue - percentComplete
Number
- fps
Number
Frames per second - avgFps
Number
Average frames per second - eta
String
Estimated time until completion - task
String
Task description, either "Encoding" or "Muxing"
###event: "output"
An aggregate of stdout
and stderr
output from the underlying HandbrakeCLI process.
###event: "error"
All operational exceptions are delivered via this event. Emits one of five types of Error
instance:
- HandbrakeCLINotFound
- HandbrakeCLIError
- NoTitleFound
- HandbrakeCLICrash
- InvalidOption
###event: "end"
Fired on successful completion of an encoding task. Always follows a begin
event, with some progress
in between.
###event: "complete" Fired when HandbrakeCLI ended cleanly. This doesn't necessarily mean your encode completed as planned..