// Used to concatinate audio files with ffmpeg and retunrs the path to the concatinated file function concatAudioFiles(filePaths, cb) { if (filePaths.length == 1) { cb(null, filePaths[0]); } else { var ffmpegCmd = ffmpeg(); const singleFilePath = path.join(workingDir, 'article.mp3'); filePaths.forEach((x) => { ffmpegCmd.input(x); }); ffmpegCmd .setFfmpegPath(ffmpegStatic.path) .setFfprobePath(ffprobeStatic.path) .on('error', (err) => { cb(err, null); }) .on('end', () => { cb(null, singleFilePath); }) .mergeToFile(singleFilePath, workingDir); } }
function cancatVideos(name,format,allTime,len){ let videoNames = getVideoNames(name,format,len).videoArr; videoNames.forEach(function(videoName){ mergedVideo = mergedVideo.addInput(videoName); }); mergedVideo.mergeToFile(getVideoNames(name,format,len).videoAll, '../tmp/') .on('error', function(err) { console.log('Error ' + err.message); }) .on('progress', function(progress) { let timeMark = timeToMs(progress.timemark); pb.render({ completed: timeMark ? timeMark : 0, total: allTime }); }) .on('end', function() { console.log('\nFinished!'); }); }