diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-02 16:05:44 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-02 16:05:44 +0200 |
commit | ebb9e53ada156249ed8e8cfd1de74097d3eb49d7 (patch) | |
tree | 094873e9f09a30eedf48617d4af3d4a3232df0fb /server/controllers/api/videos | |
parent | 22df69fdecf299c8be6acaa25f086249ea9a0085 (diff) | |
download | PeerTube-ebb9e53ada156249ed8e8cfd1de74097d3eb49d7.tar.gz PeerTube-ebb9e53ada156249ed8e8cfd1de74097d3eb49d7.tar.zst PeerTube-ebb9e53ada156249ed8e8cfd1de74097d3eb49d7.zip |
Add plugin hook on transcoding resolutions building
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/transcoding.ts | 11 |
1 files changed, 10 insertions, 1 deletions
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' | |||
4 | import { addTranscodingJob } from '@server/lib/video' | 4 | import { addTranscodingJob } from '@server/lib/video' |
5 | import { HttpStatusCode, UserRight, VideoState, VideoTranscodingCreate } from '@shared/models' | 5 | import { HttpStatusCode, UserRight, VideoState, VideoTranscodingCreate } from '@shared/models' |
6 | import { asyncMiddleware, authenticate, createTranscodingValidator, ensureUserHasRight } from '../../../middlewares' | 6 | import { asyncMiddleware, authenticate, createTranscodingValidator, ensureUserHasRight } from '../../../middlewares' |
7 | import { Hooks } from '@server/lib/plugins/hooks' | ||
7 | 8 | ||
8 | const lTags = loggerTagsFactory('api', 'video') | 9 | const lTags = loggerTagsFactory('api', 'video') |
9 | const transcodingRouter = express.Router() | 10 | const transcodingRouter = express.Router() |
@@ -30,7 +31,15 @@ async function createTranscoding (req: express.Request, res: express.Response) { | |||
30 | const body: VideoTranscodingCreate = req.body | 31 | const body: VideoTranscodingCreate = req.body |
31 | 32 | ||
32 | const { resolution: maxResolution, isPortraitMode, audioStream } = await video.probeMaxQualityFile() | 33 | const { resolution: maxResolution, isPortraitMode, audioStream } = await video.probeMaxQualityFile() |
33 | const resolutions = computeLowerResolutionsToTranscode(maxResolution, 'vod').concat([ maxResolution ]) | 34 | const resolutions = await Hooks.wrapObject( |
35 | computeLowerResolutionsToTranscode(maxResolution, 'vod').concat([ maxResolution ]), | ||
36 | 'filter:transcoding.manual.lower-resolutions-to-transcode.result', | ||
37 | body | ||
38 | ) | ||
39 | |||
40 | if (resolutions.length === 0) { | ||
41 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | ||
42 | } | ||
34 | 43 | ||
35 | video.state = VideoState.TO_TRANSCODE | 44 | video.state = VideoState.TO_TRANSCODE |
36 | await video.save() | 45 | await video.save() |