|
@@ -5,6 +5,8 @@ var path = require("path"),
|
5
|
5
|
serverSettings = require("../settings/"),
|
6
|
6
|
transports = require("../lib/transports/"),
|
7
|
7
|
logger = require("../lib/logger/"),
|
|
8
|
+ Profiler = require("../lib/profiler.js"),
|
|
9
|
+ probe = require("../lib/probe.js"),
|
8
|
10
|
getWaveform = require("./waveform.js"),
|
9
|
11
|
initializeCanvas = require("./initialize-canvas.js"),
|
10
|
12
|
drawFrames = require("./draw-frames.js"),
|
|
@@ -24,6 +26,8 @@ function Audiogram(settings) {
|
24
|
26
|
this.videoPath = path.join(this.dir, "video.mp4");
|
25
|
27
|
this.frameDir = path.join(this.dir, "frames");
|
26
|
28
|
|
|
29
|
+ this.profiler = new Profiler();
|
|
30
|
+
|
27
|
31
|
return this;
|
28
|
32
|
|
29
|
33
|
}
|
|
@@ -33,13 +37,31 @@ Audiogram.prototype.getWaveform = function(cb) {
|
33
|
37
|
|
34
|
38
|
var self = this;
|
35
|
39
|
|
36
|
|
- this.status("waveform");
|
|
40
|
+ this.status("probing");
|
|
41
|
+
|
|
42
|
+ probe(this.audioPath, function(err, data){
|
|
43
|
+
|
|
44
|
+ if (err) {
|
|
45
|
+ return cb(err);
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ if (self.settings.maxDuration && self.settings.maxDuration < data.duration) {
|
|
49
|
+ return cb("Exceeds max duration of " + self.settings.maxDuration + "s");
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ self.profiler.size(data.duration);
|
|
53
|
+ self.set("numFrames", self.numFrames = Math.floor(data.duration * self.settings.framesPerSecond));
|
|
54
|
+ self.status("waveform");
|
37
|
55
|
|
38
|
|
- getWaveform(this.audioPath, this.settings, function(err, waveform){
|
|
56
|
+ getWaveform(self.audioPath, {
|
|
57
|
+ numFrames: self.numFrames,
|
|
58
|
+ samplesPerFrame: self.settings.samplesPerFrame
|
|
59
|
+ }, function(waveformErr, waveform){
|
|
60
|
+
|
|
61
|
+ return cb(waveformErr, self.settings.waveform = waveform);
|
39
|
62
|
|
40
|
|
- self.set("numFrames", self.numFrames = waveform.length);
|
|
63
|
+ });
|
41
|
64
|
|
42
|
|
- return cb(err, self.settings.waveform = waveform);
|
43
|
65
|
|
44
|
66
|
});
|
45
|
67
|
|
|
@@ -154,6 +176,8 @@ Audiogram.prototype.render = function(cb) {
|
154
|
176
|
self.set("url", transports.getURL(self.id));
|
155
|
177
|
}
|
156
|
178
|
|
|
179
|
+ logger.debug(self.profiler.print());
|
|
180
|
+
|
157
|
181
|
return cb(err);
|
158
|
182
|
|
159
|
183
|
});
|
|
@@ -170,6 +194,7 @@ Audiogram.prototype.set = function(field, value) {
|
170
|
194
|
|
171
|
195
|
// Convenience method for .set("status")
|
172
|
196
|
Audiogram.prototype.status = function(value) {
|
|
197
|
+ this.profiler.start(value);
|
173
|
198
|
return this.set("status", value);
|
174
|
199
|
};
|
175
|
200
|
|