-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Passing a custom HandbrakeCLIPath now works correctly. Fixes #77
- Loading branch information
Showing
8 changed files
with
99 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import hbjs from 'handbrake-js' | ||
import path from 'path' | ||
import currentModulePaths from 'current-module-paths' | ||
const { __dirname } = currentModulePaths(import.meta.url) | ||
|
||
async function start () { | ||
const options = { | ||
input: path.resolve(__dirname, '../test/video/demo.mkv'), | ||
output: './tmp/output.mp4', | ||
preset: 'Very Fast 480p30', | ||
HandbrakeCLIPath: './tmp/HandbrakeCLI' | ||
} | ||
|
||
const result = await hbjs.run(options) | ||
console.log(result) | ||
} | ||
|
||
start().catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import hbjs from 'handbrake-js' | ||
import path from 'path' | ||
import currentModulePaths from 'current-module-paths' | ||
const { __dirname } = currentModulePaths(import.meta.url) | ||
|
||
const options = { | ||
input: path.resolve(__dirname, '../test/video/demo.mkv'), | ||
output: 'output.mp4', | ||
preset: 'Very Fast 480p30', | ||
HandbrakeCLIPath: './tmp/HandbrakeCLI' | ||
} | ||
|
||
/* | ||
Transcodes the input .mkv to an .mp4 using the 'Normal' preset. | ||
Using spawn enables you to track progress while encoding, | ||
more appropriate for long-running tasks. | ||
*/ | ||
hbjs.spawn(options) | ||
.on('error', console.error) | ||
.on('output', process.stdout.write.bind(process.stdout)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,10 @@ | |
"test-runner": "^0.11.0" | ||
}, | ||
"standard": { | ||
"ignore": [ | ||
"tmp", | ||
"dist" | ||
], | ||
"envs": [ | ||
"node" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import TestRunner from 'test-runner' | ||
import hbjs from 'handbrake-js' | ||
import { strict as a } from 'assert' | ||
import path from 'path' | ||
import fs from 'fs' | ||
|
||
const tom = new TestRunner.Tom() | ||
|
||
if (process.platform === 'darwin') { | ||
tom.before('Copy HandbrakeCLI to a different location', async function() { | ||
try { | ||
fs.mkdirSync('./tmp') | ||
} catch (err) { | ||
if (err.code !== 'EEXIST') { | ||
throw err | ||
} | ||
} | ||
fs.cpSync('./bin/HandbrakeCLI', './tmp/HandbrakeCLI') | ||
}) | ||
|
||
tom.test('hbjs:run() - Use custom HandbrakeCLI path', async function () { | ||
const options = { | ||
input: './test/video/demo.mkv', | ||
output: './tmp/output.mp4', | ||
preset: 'Very Fast 480p30', | ||
HandbrakeCLIPath: './tmp/HandbrakeCLI' | ||
} | ||
|
||
const result = await hbjs.run(options) | ||
a.ok(/Encode done!/.test(result.stderr)) | ||
}) | ||
} | ||
|
||
|
||
export default tom |