Video encoding / transcoding / converting for node.js
OTHER License
Upgraders, please read the release notes.
Handbrake-js is Handbrake (v1.6.1) for node.js. It aspires to provide a lean and stable foundation for building video transcoding software in node.js.
HandBrake is a tool for converting video from nearly any format to a selection of modern, widely supported codecs. It can process most common multimedia files and any DVD or BluRay sources that do not contain any copy protection.
Outputs:
Tested on Mac OSX, Ubuntu 14, Windows XP, Windows 7 and Windows 8.1.
Ubuntu 14.04 notice: Transcoding to MP4 fails on Ubuntu since 14.04 for this reason.
Just node.js. On Mac and Windows, every else is installed automatically. However on Linux, you must install HandbrakeCLI manually with these commands:
sudo add-apt-repository --yes ppa:stebbins/handbrake-releases
sudo apt-get update -qq
sudo apt-get install -qq handbrake-cli
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.
const hbjs = require('handbrake-js')
hbjs.spawn({ input: 'something.avi', output: 'something.m4v' })
.on('error', err => {
// invalid user input, no video found etc
})
.on('progress', progress => {
console.log(
'Percent complete: %s, ETA: %s',
progress.percentComplete,
progress.eta
)
})
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
In some situations or environments (e.g. Docker) you may need to specify a custom HandbrakeCLI path. You can either specify the path in an environment variable:
HANDBRAKECLI_PATH="./example/HandbrakeCLI"
..or pass HandbrakeCLIPath
as an option, programmatically. See the API documentation below for instructions. Also, see the examples folder for example code.
{{#module name="handbrake-js"}} {{>body~}} {{>member-index~}} {{>separator~}} {{>members~}} {{/module}}
© 2013-24 Lloyd Brookes <[email protected]>.
Tested by test-runner. Documented by jsdoc-to-markdown.
Handbrake (Authors) is licensed by GNU General Public License Version 2.