-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
42 lines (33 loc) · 853 Bytes
/
index.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
var merge = require('lodash.merge')
var ffmpeg = require('fluent-ffmpeg')
var version = require('./package.json').version
module.exports = exports = function (inputs, opts) {
return new Audioconcat(inputs, opts)
}
exports.VERSION = version
exports.ffmpeg = ffmpeg
function Audioconcat(inputs, opts) {
this.inputs = inputs || []
this.opts = opts || {}
}
Audioconcat.prototype.options = function (opts) {
merge(this.opts, opts)
return this
}
Audioconcat.prototype.concat = function (file) {
if (file) {
this.opts.output = file
}
return concat(this.inputs, this.opts)
}
function concat(inputs, opts) {
var filter = 'concat:' + inputs.join('|')
var renderer = ffmpeg()
.input(filter)
.outputOptions('-acodec copy')
var output = opts.output
if (output) {
return renderer.save(output)
}
return renderer
}