]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/transcoding.ts
Fix resolution to transcode hook name
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / transcoding.ts
index da3ea3c9c0abce4bb238933fbeddad2771e8399c..7d924c5ac4b4f863d891bcfd0ea107bc9a294bec 100644 (file)
@@ -1,9 +1,10 @@
 import express from 'express'
-import { computeLowerResolutionsToTranscode } from '@server/helpers/ffmpeg'
+import { computeResolutionsToTranscode } from '@server/helpers/ffmpeg'
 import { logger, loggerTagsFactory } from '@server/helpers/logger'
 import { addTranscodingJob } from '@server/lib/video'
 import { HttpStatusCode, UserRight, VideoState, VideoTranscodingCreate } from '@shared/models'
 import { asyncMiddleware, authenticate, createTranscodingValidator, ensureUserHasRight } from '../../../middlewares'
+import { Hooks } from '@server/lib/plugins/hooks'
 
 const lTags = loggerTagsFactory('api', 'video')
 const transcodingRouter = express.Router()
@@ -29,8 +30,16 @@ async function createTranscoding (req: express.Request, res: express.Response) {
 
   const body: VideoTranscodingCreate = req.body
 
-  const { resolution: maxResolution, isPortraitMode, audioStream } = await video.probeMaxQualityFile()
-  const resolutions = computeLowerResolutionsToTranscode(maxResolution, 'vod').concat([ maxResolution ])
+  const { resolution: maxResolution, audioStream } = await video.probeMaxQualityFile()
+  const resolutions = await Hooks.wrapObject(
+    computeResolutionsToTranscode({ inputResolution: maxResolution, type: 'vod', includeInputResolution: true }),
+    'filter:transcoding.manual.resolutions-to-transcode.result',
+    body
+  )
+
+  if (resolutions.length === 0) {
+    return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
+  }
 
   video.state = VideoState.TO_TRANSCODE
   await video.save()
@@ -41,7 +50,6 @@ async function createTranscoding (req: express.Request, res: express.Response) {
         type: 'new-resolution-to-hls',
         videoUUID: video.uuid,
         resolution,
-        isPortraitMode,
         hasAudio: !!audioStream,
         copyCodecs: false,
         isNewVideo: false,
@@ -55,8 +63,7 @@ async function createTranscoding (req: express.Request, res: express.Response) {
         isNewVideo: false,
         resolution,
         hasAudio: !!audioStream,
-        createHLSIfNeeded: false,
-        isPortraitMode
+        createHLSIfNeeded: false
       })
     }
   }