+ hlsPlaylist.playlistFilename = generateHLSMasterPlaylistFilename()
+ hlsPlaylist.segmentsSha256Filename = generateHlsSha256SegmentsFilename()
+ await hlsPlaylist.save()
+
+ await assignReplayFilesToVideo({ video: videoWithFiles, replayDirectory })
+
+ if (live.permanentLive) { // Remove session replay
+ await remove(replayDirectory)
+ } else { // We won't stream again in this live, we can delete the base replay directory
+ await remove(getLiveReplayBaseDirectory(videoWithFiles))
+ }
+
+ // Regenerate the thumbnail & preview?
+ if (videoWithFiles.getMiniature().automaticallyGenerated === true) {
+ const miniature = await generateVideoMiniature({
+ video: videoWithFiles,
+ videoFile: videoWithFiles.getMaxQualityFile(),
+ type: ThumbnailType.MINIATURE
+ })
+ await videoWithFiles.addAndSaveThumbnail(miniature)
+ }
+
+ if (videoWithFiles.getPreview().automaticallyGenerated === true) {
+ const preview = await generateVideoMiniature({
+ video: videoWithFiles,
+ videoFile: videoWithFiles.getMaxQualityFile(),
+ type: ThumbnailType.PREVIEW
+ })
+ await videoWithFiles.addAndSaveThumbnail(preview)
+ }
+
+ // We consider this is a new video
+ await moveToNextState({ video: videoWithFiles, isNewVideo: true })
+}
+
+async function assignReplayFilesToVideo (options: {
+ video: MVideo
+ replayDirectory: string
+}) {
+ const { video, replayDirectory } = options
+
+ let durationDone = false