You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
695 B
19 lines
695 B
const fs = require('fs-extra');
|
|
|
|
const getFfmpegCommonArgs = ({ enableFfmpegLog }) => (enableFfmpegLog ? [] : ['-hide_banner', '-loglevel', 'error']);
|
|
|
|
const getCutFromArgs = ({ cutFrom }) => (cutFrom ? ['-ss', cutFrom] : []);
|
|
|
|
const getCutToArgs = ({ cutTo, cutFrom, speedFactor }) => (cutTo ? ['-t', (cutTo - cutFrom) * speedFactor] : []);
|
|
|
|
async function createConcatFile(segments, concatFilePath) {
|
|
// https://superuser.com/questions/787064/filename-quoting-in-ffmpeg-concat
|
|
await fs.writeFile(concatFilePath, segments.map((seg) => `file '${seg.replace(/'/g, "'\\''")}'`).join('\n'));
|
|
}
|
|
|
|
module.exports = {
|
|
getFfmpegCommonArgs,
|
|
getCutFromArgs,
|
|
getCutToArgs,
|
|
createConcatFile,
|
|
};
|