-
Notifications
You must be signed in to change notification settings - Fork 144
/
worker-asm.js
62 lines (49 loc) · 1.4 KB
/
worker-asm.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
52
53
54
55
56
57
58
59
60
61
62
// this file is used to run ffmpeg_asm.js!
// however, it is included in the HTML as "processInWebWorker" method instead of linking as a separate javascript file!
importScripts('https://googledrive.com/host/0B6GWd_dUUTT8OEtLRGdQb2pibDg/ffmpeg_asm.js');
var now = Date.now;
function print(text) {
postMessage({
'type' : 'stdout',
'data' : text
});
}
onmessage = function(event) {
var message = event.data;
if (message.type === "command") {
var Module = {
print: print,
printErr: print,
files: message.files || [],
arguments: message.arguments || [],
TOTAL_MEMORY: message.TOTAL_MEMORY || false
// Can play around with this option - must be a power of 2
// TOTAL_MEMORY: 268435456
};
postMessage({
'type' : 'start',
'data' : Module.arguments.join(" ")
});
postMessage({
'type' : 'stdout',
'data' : 'Received command: ' +
Module.arguments.join(" ") +
((Module.TOTAL_MEMORY) ? ". Processing with " + Module.TOTAL_MEMORY + " bits." : "")
});
var time = now();
var result = ffmpeg_run(Module);
var totalTime = now() - time;
postMessage({
'type' : 'stdout',
'data' : 'Finished processing (took ' + totalTime + 'ms)'
});
postMessage({
'type' : 'done',
'data' : result,
'time' : totalTime
});
}
};
postMessage({
'type' : 'ready'
});