const streamingPlaylist = video.getHLSPlaylist()
for (const file of streamingPlaylist.VideoFiles) {
+ const playlistFilename = VideoStreamingPlaylistModel.getHlsPlaylistFilename(file.resolution)
+
// If we did not generated a playlist for this resolution, skip
- const filePlaylistPath = join(directory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(file.resolution))
+ const filePlaylistPath = join(directory, playlistFilename)
if (await pathExists(filePlaylistPath) === false) continue
const videoFilePath = getVideoFilePath(streamingPlaylist, file)
let line = `#EXT-X-STREAM-INF:${bandwidth},${resolution}`
if (file.fps) line += ',FRAME-RATE=' + file.fps
- const videoCodec = await getVideoStreamCodec(videoFilePath)
- line += `,CODECS="${videoCodec}`
-
- const audioCodec = await getAudioStreamCodec(videoFilePath)
- if (audioCodec) line += `,${audioCodec}`
+ const codecs = await Promise.all([
+ getVideoStreamCodec(videoFilePath),
+ getAudioStreamCodec(videoFilePath)
+ ])
- line += '"'
+ line += `,CODECS="${codecs.filter(c => !!c).join(',')}"`
masterPlaylists.push(line)
- masterPlaylists.push(VideoStreamingPlaylistModel.getHlsPlaylistFilename(file.resolution))
+ masterPlaylists.push(playlistFilename)
}
await writeFile(masterPlaylistPath, masterPlaylists.join('\n') + '\n')