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/lib | |
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/lib')
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 8 | ||||
-rw-r--r-- | server/lib/live/live-manager.ts | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 1b34ced14..d3fb7778b 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -26,6 +26,7 @@ import { | |||
26 | optimizeOriginalVideofile, | 26 | optimizeOriginalVideofile, |
27 | transcodeNewWebTorrentResolution | 27 | transcodeNewWebTorrentResolution |
28 | } from '../../transcoding/transcoding' | 28 | } from '../../transcoding/transcoding' |
29 | import { Hooks } from '@server/lib/plugins/hooks' | ||
29 | 30 | ||
30 | type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void> | 31 | type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void> |
31 | 32 | ||
@@ -269,7 +270,12 @@ async function createLowerResolutionsJobs (options: { | |||
269 | const { video, user, videoFileResolution, isPortraitMode, isNewVideo, hasAudio, type } = options | 270 | const { video, user, videoFileResolution, isPortraitMode, isNewVideo, hasAudio, type } = options |
270 | 271 | ||
271 | // Create transcoding jobs if there are enabled resolutions | 272 | // Create transcoding jobs if there are enabled resolutions |
272 | const resolutionsEnabled = computeLowerResolutionsToTranscode(videoFileResolution, 'vod') | 273 | const resolutionsEnabled = await Hooks.wrapObject( |
274 | computeLowerResolutionsToTranscode(videoFileResolution, 'vod'), | ||
275 | 'filter:transcoding.auto.lower-resolutions-to-transcode.result', | ||
276 | options | ||
277 | ) | ||
278 | |||
273 | const resolutionCreated: string[] = [] | 279 | const resolutionCreated: string[] = [] |
274 | 280 | ||
275 | for (const resolution of resolutionsEnabled) { | 281 | for (const resolution of resolutionsEnabled) { |
diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts index 41f89a2a4..bd47b01f9 100644 --- a/server/lib/live/live-manager.ts +++ b/server/lib/live/live-manager.ts | |||
@@ -29,6 +29,7 @@ import { PeerTubeSocket } from '../peertube-socket' | |||
29 | import { LiveQuotaStore } from './live-quota-store' | 29 | import { LiveQuotaStore } from './live-quota-store' |
30 | import { cleanupPermanentLive } from './live-utils' | 30 | import { cleanupPermanentLive } from './live-utils' |
31 | import { MuxingSession } from './shared' | 31 | import { MuxingSession } from './shared' |
32 | import { Hooks } from '../plugins/hooks' | ||
32 | 33 | ||
33 | const NodeRtmpSession = require('node-media-server/src/node_rtmp_session') | 34 | const NodeRtmpSession = require('node-media-server/src/node_rtmp_session') |
34 | const context = require('node-media-server/src/node_core_ctx') | 35 | const context = require('node-media-server/src/node_core_ctx') |
@@ -242,7 +243,11 @@ class LiveManager { | |||
242 | inputUrl, Date.now() - now, bitrate, fps, resolution, lTags(sessionId, video.uuid) | 243 | inputUrl, Date.now() - now, bitrate, fps, resolution, lTags(sessionId, video.uuid) |
243 | ) | 244 | ) |
244 | 245 | ||
245 | const allResolutions = this.buildAllResolutionsToTranscode(resolution) | 246 | const allResolutions = await Hooks.wrapObject( |
247 | this.buildAllResolutionsToTranscode(resolution), | ||
248 | 'filter:transcoding.auto.lower-resolutions-to-transcode.result', | ||
249 | { video } | ||
250 | ) | ||
246 | 251 | ||
247 | logger.info( | 252 | logger.info( |
248 | 'Will mux/transcode live video of original resolution %d.', resolution, | 253 | 'Will mux/transcode live video of original resolution %d.', resolution, |