forked from adblockradio/stream-audio-fingerprint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen_demo.js
51 lines (44 loc) · 1.2 KB
/
codegen_demo.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
46
47
48
49
50
51
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (c) 2018 Alexandre Storelli
const md5 = require('md5');
const decoder = require('child_process').spawn('ffmpeg', [
'-i', 'pipe:0',
'-acodec', 'pcm_s16le',
'-ar', 22050,
'-ac', 1,
'-f', 'wav',
'-v', 'fatal',
'pipe:1'
], { stdio: ['pipe', 'pipe', process.stderr] });
process.stdin.pipe(decoder.stdin); //.write(data);
/**
* BEGIN TEMP
*/
/*
process.stdin.on("data", function(data) {
console.log(data);
});
decoder.stdout.on("end", function() {
console.log("stream ended");
});
*/
decoder.stdout.on("data", function(data) {
// to compare outputs from ffmpeg
// console.log(md5(data.toString()));
});
/**
* END TEMP
*/
const Codegen = require("./codegen_landmark.js");
const fingerprinter = new Codegen();
decoder.stdout.pipe(fingerprinter);
fingerprinter.on("data", function(data) {
for (let i=0; i<data.tcodes.length; i++) {
console.log("time=" + data.tcodes[i] + " fingerprint=" + data.hcodes[i]);
}
});
fingerprinter.on("end", function() {
// console.log("fingerprints stream ended");
});