+ const videoOutputPath = getVideoFilePath(video, inputVideoFile)
+ // ffmpeg generated a new video file, so update the video duration
+ // See https://trac.ffmpeg.org/ticket/5456
+ video.duration = await getDurationFromVideoFile(videoTranscodedPath)
+ await video.save()
+
+ return onWebTorrentVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath)
+}
+
+// Concat TS segments from a live video to a fragmented mp4 HLS playlist
+async function generateHlsPlaylistResolutionFromTS (options: {
+ video: MVideoWithFile
+ concatenatedTsFilePath: string
+ resolution: VideoResolution
+ isPortraitMode: boolean
+ isAAC: boolean
+}) {
+ return generateHlsPlaylistCommon({
+ video: options.video,
+ resolution: options.resolution,
+ isPortraitMode: options.isPortraitMode,
+ inputPath: options.concatenatedTsFilePath,
+ type: 'hls-from-ts' as 'hls-from-ts',
+ isAAC: options.isAAC
+ })
+}
+
+// Generate an HLS playlist from an input file, and update the master playlist
+function generateHlsPlaylistResolution (options: {
+ video: MVideoWithFile
+ videoInputPath: string
+ resolution: VideoResolution
+ copyCodecs: boolean
+ isPortraitMode: boolean
+ job?: Job
+}) {
+ return generateHlsPlaylistCommon({
+ video: options.video,
+ resolution: options.resolution,
+ copyCodecs: options.copyCodecs,
+ isPortraitMode: options.isPortraitMode,
+ inputPath: options.videoInputPath,
+ type: 'hls' as 'hls',
+ job: options.job
+ })
+}
+
+function getEnabledResolutions (type: 'vod' | 'live') {
+ const transcoding = type === 'vod'
+ ? CONFIG.TRANSCODING
+ : CONFIG.LIVE.TRANSCODING