+ const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(uuid)
+ if (!video) throw new Error('Video not found.')
+
+ const dataInput: VideoTranscodingPayload[] = []
+ const resolution = video.getMaxQualityFile().resolution
+
+ // Generate HLS files
+ if (options.generateHls || CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
+ const resolutionsEnabled = options.resolution
+ ? [ options.resolution ]
+ : computeResolutionsToTranscode(resolution, 'vod').concat([ resolution ])
+
+ for (const resolution of resolutionsEnabled) {
+ dataInput.push({
+ type: 'new-resolution-to-hls',
+ videoUUID: video.uuid,
+ resolution,
+ isPortraitMode: false,
+ copyCodecs: false,
+ isNewVideo: false,
+ isMaxQuality: false
+ })
+ }
+ } else {
+ if (options.resolution !== undefined) {
+ dataInput.push({
+ type: 'new-resolution-to-webtorrent',
+ videoUUID: video.uuid,
+ isNewVideo: false,
+ resolution: options.resolution
+ })
+ } else {
+ if (video.VideoFiles.length === 0) {
+ console.error('Cannot regenerate webtorrent files with a HLS only video.')
+ return
+ }
+
+ dataInput.push({
+ type: 'optimize-to-webtorrent',
+ videoUUID: video.uuid,
+ isNewVideo: false
+ })
+ }