-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcombine.js
More file actions
54 lines (41 loc) · 1.3 KB
/
combine.js
File metadata and controls
54 lines (41 loc) · 1.3 KB
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
46
47
48
49
50
51
52
53
//command to run the file
//ls -1 *file.txt | xargs -t -n1 node combine.js
const fs = require('fs');
const readline = require('readline');
const execSync = require('child_process').execSync;
if (process.argv.length <= 2) {
console.log("Usage: " + __filename + " path/to/file");
process.exit(-1);
}
const path = process.argv[2];
let rl = readline.createInterface({
input: fs.createReadStream(path)
});
let line_no = 0;
let combFile = path;
combFile = combFile.replace('_file.txt','_combined.m4a');
let aacComb = combFile;
aacComb = aacComb.replace('m4a','aac');
// event is emitted after each line
rl.on('line', function(line) {
line_no++;
console.log('Processing: ' + line);
//Convert the files
let m4afile = line.replace(/file (.*)/i,'$1');
let aacfile = m4afile;
aacfile = aacfile.replace('m4a','aac');
const aacCmd = 'ffmpeg -y -i ' + m4afile + ' -acodec copy ' + aacfile;
console.log("Converting... - " + aacCmd);
execSync(aacCmd);
//Concatenate the files
const catCmd = 'cat ' + aacfile + ' >>' + aacComb;
console.log("Concatenating... - " + catCmd);
execSync(catCmd);
});
// end
rl.on('close', function(line) {
//Combine
const combCmd = 'ffmpeg -y -i ' + aacComb + ' -acodec copy -bsf:a aac_adtstoasc ' + combFile;
console.log("Combining... - " + combCmd);
execSync(combCmd);
});