forked from RReverser/mpegts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.js
51 lines (45 loc) · 1.16 KB
/
worker.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
'use strict';
importScripts('./lib/require.js');
require.config({
paths: {
jdataview: '//jdataview.github.io/dist/jdataview',
jbinary: '//jdataview.github.io/dist/jbinary',
async: 'lib/async',
consoleTime: './shim/console.time',
consoleWorker: './shim/console.worker'
},
shim: {
consoleTime: {
deps: ['consoleWorker'],
exports: 'console'
},
consoleWorker: {
deps: [],
exports: 'console'
}
}
});
require(['async', 'jbinary', './mpegts_to_mp4/mpegts', './mpegts_to_mp4/index', 'consoleTime', 'consoleWorker'],
function (async, jBinary, MPEGTS, mpegts_to_mp4) {
addEventListener('message', function (event) {
// processing received sources one by one
async.eachSeries(event.data, function (msg, callback) {
jBinary.load(msg.url, MPEGTS, function (err, mpegts) {
// tell async we can load next one
callback(err);
if (err) return;
console.time('convert');
var mp4 = mpegts_to_mp4(mpegts);
console.timeEnd('convert');
postMessage({
type: 'video',
index: msg.index,
original: msg.url,
url: mp4.toURI('video/mp4')
});
});
});
});
postMessage({type: 'ready'});
}
);