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(); await worker.load();
const { data } = await worker.transcode(inputPath, outputPath.split('.').pop()); const { data } = await worker.transcode(inputPath, outputPath.split('.').pop());
fs.writeFileSync(outputPath, Buffer.from(data)); fs.writeFileSync(outputPath, Buffer.from(data));
process.exit(0);
})(); })();

14
package-lock.json generated
View File

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

View File

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

View File

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