Enable log output and remove video file from wasm mem after transcode

This commit is contained in:
Jerome Wu 2019-10-30 16:21:21 +08:00
parent ff4ae62146
commit 1e558c3a36
4 changed files with 8 additions and 14 deletions

View File

@ -10,4 +10,5 @@ const worker = createWorker();
await worker.load();
const { data } = await worker.transcode(inputPath, outputPath.split('.').pop());
fs.writeFileSync(outputPath, Buffer.from(data));
process.exit(0);
})();

14
package-lock.json generated
View File

@ -3077,14 +3077,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -3104,8 +3102,7 @@
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
@ -3253,7 +3250,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -3261,14 +3257,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -3287,7 +3281,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -3380,7 +3373,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}

View File

@ -1,6 +1,4 @@
module.exports = [
'./ffmpeg', // args[0] is always binary path
'-nostdin', // Disable interaction mode
'-loglevel',
'quiet',
];

View File

@ -52,7 +52,10 @@ const transcode = ({
const args = [...defaultArgs, ...`${options} -i file:${iPath} ${oPath}`.trim().split(' ')];
Module.FS.writeFile(iPath, data);
ffmpeg(args.length, strList2ptr(args));
res.resolve(Module.FS.readFile(oPath));
const out = Module.FS.readFile(oPath);
Module.FS.unlink(iPath);
Module.FS.unlink(oPath);
res.resolve(out);
};
exports.dispatchHandlers = (packet, send) => {