forked from little-core-labs/little-media-box
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.js
45 lines (38 loc) · 937 Bytes
/
configure.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const { ffmpeg } = require('./ffmpeg')
const settings = require('./settings')
/**
* Configures module level settings like binary paths
* for various commands (ffmpeg, ffprobe, mkvmerge, x264)
* and shared settings between functions.
* @public
* @param {?(Object)} opts
* @param {?(Object)} opts.bin
* @param {?(String)} opts.bin.ffmpeg
* @param {?(String)} opts.bin.ffprobe
*/
function configure(opts) {
if (!opts || 'object' !== typeof opts) {
opts = {}
}
if (opts.bin) {
if ('string' === typeof opts.bin.ffmpeg) {
settings.bin.ffmpeg = opts.bin.ffmpeg
}
if ('string' === typeof opts.bin.ffprobe) {
settings.bin.ffprobe = opts.bin.ffprobe
}
}
if (settings.bin.ffmpeg) {
ffmpeg.setFfmpegPath(settings.bin.ffmpeg)
}
if (settings.bin.ffprobe) {
ffmpeg.setFfprobePath(opts.bin.ffprobe)
}
return settings
}
/**
* Module exports.
*/
module.exports = {
configure
}