- // Playlist name is for example 3.m3u8
- // Segments names are 3-0.ts 3-1.ts etc
- const shouldStartWith = playlistFile.replace(/\.m3u8$/, '') + '-'
-
- const segmentFiles = files.filter(f => f.startsWith(shouldStartWith) && f.endsWith('.ts'))
- await hlsPlaylistToFragmentedMP4(hlsDirectory, segmentFiles, mp4TmpName)
-
- for (const file of segmentFiles) {
- await remove(join(hlsDirectory, file))
- }
-
- if (!duration) {
- duration = await getDurationFromVideoFile(mp4TmpName)
- }