-function hlsPlaylistToFragmentedMP4 (playlistPath: string, outputPath: string) {
- const command = getFFmpeg(playlistPath)
+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')