return command
}
+async function hlsPlaylistToFragmentedMP4 (hlsDirectory: string, segmentFiles: string[], outputPath: string) {
+ const concatFile = 'concat.txt'
+ const concatFilePath = join(hlsDirectory, concatFile)
+ const content = segmentFiles.map(f => 'file ' + f)
+ .join('\n')
+
+ await writeFile(concatFilePath, content + '\n')
+
+ const command = getFFmpeg(concatFilePath)
+ command.inputOption('-safe 0')
+ command.inputOption('-f concat')
+
+ command.outputOption('-c copy')
+ command.output(outputPath)
+
+ command.run()
+
+ function cleaner () {
+ remove(concatFile)
+ .catch(err => logger.error('Cannot remove concat file in %s.', hlsDirectory, { err }))
+ }
+
+ return new Promise<string>((res, rej) => {
+ command.on('error', err => {
+ cleaner()
+
+ rej(err)
+ })
+
+ command.on('end', () => {
+ cleaner()
+
+ res()
+ })
+ })
+}
+
// ---------------------------------------------------------------------------
export {
getVideoFileFPS,
computeResolutionsToTranscode,
audio,
+ hlsPlaylistToFragmentedMP4,
getVideoFileBitrate,
canDoQuickTranscode
}