concatDemuxer implemented

This commit is contained in:
santosh898
2019-12-16 15:30:44 +05:30
parent f93ae84794
commit 68fd03d55d
4 changed files with 60 additions and 70 deletions

View File

@@ -122,9 +122,11 @@ module.exports = (_options = {}) => {
)
);
const concatDemux = (texFilePath, outputPath, opts = '', del = false, jobId) => {
run(`${opts} -f concat -safe 0 -i /data/${texFilePath} -c copy ${outputPath}`,
{ del },
const concatDemuxer = async (inputPaths, outputPath, opts = '', del = true, jobId) => {
const text = inputPaths.reduce((acc, input) => `${acc}\nfile ${input}`, '');
await writeText('concat_list.txt', text);
return run(`${opts} -f concat -safe 0 -i /data/concat_list.txt -c copy ${outputPath}`,
{ del, outputPath, inputPaths: [...inputPaths, 'concat_list.txt'] },
jobId);
};
@@ -181,7 +183,7 @@ module.exports = (_options = {}) => {
run,
transcode,
trim,
concatDemux,
concatDemuxer,
ls,
terminate,
};

View File

@@ -66,7 +66,9 @@ const ls = ({
const run = async ({
payload: {
args: _args,
options: { inputPath, outputPath, del },
options: {
inputPath, inputPaths, outputPath, del,
},
},
}, res) => {
const args = [...defaultArgs, ..._args.trim().split(' ')];
@@ -75,6 +77,9 @@ const run = async ({
Module.FS.unlink(outputPath);
if (del && typeof inputPath === 'string') {
await adapter.fs.deleteFile(inputPath);
} else if (del && Array.isArray(inputPaths)) {
inputPaths.reduce((promise, input) => promise.then(() => adapter.fs.deleteFile(input)),
Promise.resolve());
}
res.resolve({ message: `Complete ${args.join(' ')}` });
};