]> 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 44ecf4cc9b5bdc608147c70955d488ca58f51a30..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 }))
@@ -169,13 +171,15 @@ async function generateHlsPlaylistFromTS (options: {
   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'
+    type: 'hls-from-ts' as 'hls-from-ts',
+    isAAC: options.isAAC
   })
 }
 
@@ -197,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 {
@@ -204,7 +218,8 @@ export {
   generateHlsPlaylistFromTS,
   optimizeOriginalVideofile,
   transcodeNewResolution,
-  mergeAudioVideofile
+  mergeAudioVideofile,
+  getEnabledResolutions
 }
 
 // ---------------------------------------------------------------------------
@@ -234,9 +249,10 @@ async function generateHlsPlaylistCommon (options: {
   inputPath: string
   resolution: VideoResolution
   copyCodecs?: boolean
+  isAAC?: boolean
   isPortraitMode: boolean
 }) {
-  const { type, video, inputPath, resolution, copyCodecs, isPortraitMode } = options
+  const { type, video, inputPath, resolution, copyCodecs, isPortraitMode, isAAC } = options
 
   const baseHlsDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)
   await ensureDir(join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid))
@@ -257,6 +273,8 @@ async function generateHlsPlaylistCommon (options: {
     copyCodecs,
     isPortraitMode,
 
+    isAAC,
+
     hlsPlaylist: {
       videoFilename
     }