]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/video-transcoding.ts
stricter youtubedl format selectors (#3516)
[github/Chocobozzz/PeerTube.git] / server / lib / video-transcoding.ts
index e7108bd5a971dd9fec05673273d06beffd131643..a6b79eaeaa4cddfcf5465bae56a55dc9fc6f81c7 100644 (file)
@@ -59,6 +59,8 @@ async function optimizeOriginalVideofile (video: MVideoWithFile, inputVideoFileA
     const videoOutputPath = getVideoFilePath(video, inputVideoFile)
 
     await onVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath)
+
+    return transcodeType
   } catch (err) {
     // Auto destruction...
     video.destroy().catch(err => logger.error('Cannot destruct video after transcoding failure.', { err }))
@@ -199,6 +201,16 @@ function generateHlsPlaylist (options: {
   })
 }
 
+function getEnabledResolutions (type: 'vod' | 'live') {
+  const transcoding = type === 'vod'
+    ? CONFIG.TRANSCODING
+    : CONFIG.LIVE.TRANSCODING
+
+  return Object.keys(transcoding.RESOLUTIONS)
+               .filter(key => transcoding.ENABLED && transcoding.RESOLUTIONS[key] === true)
+               .map(r => parseInt(r, 10))
+}
+
 // ---------------------------------------------------------------------------
 
 export {
@@ -206,7 +218,8 @@ export {
   generateHlsPlaylistFromTS,
   optimizeOriginalVideofile,
   transcodeNewResolution,
-  mergeAudioVideofile
+  mergeAudioVideofile,
+  getEnabledResolutions
 }
 
 // ---------------------------------------------------------------------------