From 1e558c3a36fbaa30e94104083603fc48fc4695c7 Mon Sep 17 00:00:00 2001 From: Jerome Wu Date: Wed, 30 Oct 2019 16:21:21 +0800 Subject: [PATCH] Enable log output and remove video file from wasm mem after transcode --- examples/node/transcode.js | 1 + package-lock.json | 14 +++----------- src/worker-script/constants/defaultArgs.js | 2 -- src/worker-script/index.js | 5 ++++- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/examples/node/transcode.js b/examples/node/transcode.js index 024ca9c..dba722c 100755 --- a/examples/node/transcode.js +++ b/examples/node/transcode.js @@ -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); })(); diff --git a/package-lock.json b/package-lock.json index 95bde4d..b149a81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" } diff --git a/src/worker-script/constants/defaultArgs.js b/src/worker-script/constants/defaultArgs.js index 16aacaa..55aae4f 100755 --- a/src/worker-script/constants/defaultArgs.js +++ b/src/worker-script/constants/defaultArgs.js @@ -1,6 +1,4 @@ module.exports = [ './ffmpeg', // args[0] is always binary path '-nostdin', // Disable interaction mode - '-loglevel', - 'quiet', ]; diff --git a/src/worker-script/index.js b/src/worker-script/index.js index e43c791..33c50a2 100644 --- a/src/worker-script/index.js +++ b/src/worker-script/index.js @@ -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) => {