Skip to content

Commit d799260

Browse files
committed
Add doRun in worker-script
1 parent 5a90020 commit d799260

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/worker-script/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ const strList2ptr = (strList) => {
2626
return listPtr;
2727
};
2828

29+
const doRun = (_args) => {
30+
const args = [...defaultArgs, ..._args.trim().split(' ')];
31+
ffmpeg(args.length, strList2ptr(args));
32+
};
33+
2934
const load = ({ workerId, payload: { options: { corePath } } }, res) => {
3035
if (Module == null) {
3136
const Core = adapter.getCore(corePath);
@@ -63,8 +68,7 @@ const transcode = ({
6368
options = '',
6469
},
6570
}, res) => {
66-
const args = [...defaultArgs, ...`${options} -i ${inputPath} ${outputPath}`.trim().split(' ')];
67-
ffmpeg(args.length, strList2ptr(args));
71+
doRun(`${options} -i ${inputPath} ${outputPath}`);
6872
res.resolve({ message: `Complete transcoding ${inputPath} to ${outputPath}` });
6973
};
7074

@@ -78,12 +82,11 @@ const read = ({
7882

7983
const run = ({
8084
payload: {
81-
args: _args,
85+
args,
8286
},
8387
}, res) => {
84-
const args = [...defaultArgs, ..._args.trim().split(' ')];
85-
ffmpeg(args.length, strList2ptr(args));
86-
res.resolve({ message: `Complete ./ffmpeg ${_args}` });
88+
doRun(args);
89+
res.resolve({ message: `Complete ./ffmpeg ${args}` });
8790
};
8891

8992
exports.dispatchHandlers = (packet, send) => {

0 commit comments

Comments
 (0)