From ebb9e53ada156249ed8e8cfd1de74097d3eb49d7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 2 Aug 2022 16:05:44 +0200 Subject: Add plugin hook on transcoding resolutions building --- server/controllers/api/videos/transcoding.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'server/controllers') diff --git a/server/controllers/api/videos/transcoding.ts b/server/controllers/api/videos/transcoding.ts index da3ea3c9c..a360a8b6a 100644 --- a/server/controllers/api/videos/transcoding.ts +++ b/server/controllers/api/videos/transcoding.ts @@ -4,6 +4,7 @@ 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() @@ -30,7 +31,15 @@ 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 resolutions = await Hooks.wrapObject( + computeLowerResolutionsToTranscode(maxResolution, 'vod').concat([ maxResolution ]), + 'filter:transcoding.manual.lower-resolutions-to-transcode.result', + body + ) + + if (resolutions.length === 0) { + return res.sendStatus(HttpStatusCode.NO_CONTENT_204) + } video.state = VideoState.TO_TRANSCODE await video.save() -- cgit v1.2.3