diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-04 15:29:34 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2023-05-09 08:57:34 +0200 |
commit | 5e47f6ab984a7d00782e4c7030afffa1ba480add (patch) | |
tree | 1ce586b591a8d71acbc301eba29b9a5e6490439e /shared | |
parent | 6a4905602636afd6650c9e6f4d0fcc2105d91100 (diff) | |
download | PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.tar.gz PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.tar.zst PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.zip |
Support studio transcoding in peertube runner
Diffstat (limited to 'shared')
-rw-r--r-- | shared/models/runners/runner-job-payload.model.ts | 13 | ||||
-rw-r--r-- | shared/models/runners/runner-job-private-payload.model.ts | 12 | ||||
-rw-r--r-- | shared/models/runners/runner-job-success-body.model.ts | 7 | ||||
-rw-r--r-- | shared/models/runners/runner-job-type.type.ts | 3 | ||||
-rw-r--r-- | shared/models/server/custom-config.model.ts | 4 | ||||
-rw-r--r-- | shared/models/server/job.model.ts | 4 | ||||
-rw-r--r-- | shared/models/server/server-config.model.ts | 6 | ||||
-rw-r--r-- | shared/models/videos/studio/video-studio-create-edit.model.ts | 18 | ||||
-rw-r--r-- | shared/server-commands/runners/runner-jobs-command.ts | 9 | ||||
-rw-r--r-- | shared/server-commands/server/config-command.ts | 17 |
10 files changed, 86 insertions, 7 deletions
diff --git a/shared/models/runners/runner-job-payload.model.ts b/shared/models/runners/runner-job-payload.model.ts index 8f0c17135..9f0db0dc4 100644 --- a/shared/models/runners/runner-job-payload.model.ts +++ b/shared/models/runners/runner-job-payload.model.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import { VideoStudioTaskPayload } from '../server' | ||
2 | |||
1 | export type RunnerJobVODPayload = | 3 | export type RunnerJobVODPayload = |
2 | RunnerJobVODWebVideoTranscodingPayload | | 4 | RunnerJobVODWebVideoTranscodingPayload | |
3 | RunnerJobVODHLSTranscodingPayload | | 5 | RunnerJobVODHLSTranscodingPayload | |
@@ -5,7 +7,8 @@ export type RunnerJobVODPayload = | |||
5 | 7 | ||
6 | export type RunnerJobPayload = | 8 | export type RunnerJobPayload = |
7 | RunnerJobVODPayload | | 9 | RunnerJobVODPayload | |
8 | RunnerJobLiveRTMPHLSTranscodingPayload | 10 | RunnerJobLiveRTMPHLSTranscodingPayload | |
11 | RunnerJobVideoEditionTranscodingPayload | ||
9 | 12 | ||
10 | // --------------------------------------------------------------------------- | 13 | // --------------------------------------------------------------------------- |
11 | 14 | ||
@@ -43,6 +46,14 @@ export interface RunnerJobVODAudioMergeTranscodingPayload { | |||
43 | } | 46 | } |
44 | } | 47 | } |
45 | 48 | ||
49 | export interface RunnerJobVideoEditionTranscodingPayload { | ||
50 | input: { | ||
51 | videoFileUrl: string | ||
52 | } | ||
53 | |||
54 | tasks: VideoStudioTaskPayload[] | ||
55 | } | ||
56 | |||
46 | // --------------------------------------------------------------------------- | 57 | // --------------------------------------------------------------------------- |
47 | 58 | ||
48 | export function isAudioMergeTranscodingPayload (payload: RunnerJobPayload): payload is RunnerJobVODAudioMergeTranscodingPayload { | 59 | export function isAudioMergeTranscodingPayload (payload: RunnerJobPayload): payload is RunnerJobVODAudioMergeTranscodingPayload { |
diff --git a/shared/models/runners/runner-job-private-payload.model.ts b/shared/models/runners/runner-job-private-payload.model.ts index c1d8d1045..c8fe0a7d8 100644 --- a/shared/models/runners/runner-job-private-payload.model.ts +++ b/shared/models/runners/runner-job-private-payload.model.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import { VideoStudioTaskPayload } from '../server' | ||
2 | |||
1 | export type RunnerJobVODPrivatePayload = | 3 | export type RunnerJobVODPrivatePayload = |
2 | RunnerJobVODWebVideoTranscodingPrivatePayload | | 4 | RunnerJobVODWebVideoTranscodingPrivatePayload | |
3 | RunnerJobVODAudioMergeTranscodingPrivatePayload | | 5 | RunnerJobVODAudioMergeTranscodingPrivatePayload | |
@@ -5,7 +7,8 @@ export type RunnerJobVODPrivatePayload = | |||
5 | 7 | ||
6 | export type RunnerJobPrivatePayload = | 8 | export type RunnerJobPrivatePayload = |
7 | RunnerJobVODPrivatePayload | | 9 | RunnerJobVODPrivatePayload | |
8 | RunnerJobLiveRTMPHLSTranscodingPrivatePayload | 10 | RunnerJobLiveRTMPHLSTranscodingPrivatePayload | |
11 | RunnerJobVideoEditionTranscodingPrivatePayload | ||
9 | 12 | ||
10 | // --------------------------------------------------------------------------- | 13 | // --------------------------------------------------------------------------- |
11 | 14 | ||
@@ -32,3 +35,10 @@ export interface RunnerJobLiveRTMPHLSTranscodingPrivatePayload { | |||
32 | masterPlaylistName: string | 35 | masterPlaylistName: string |
33 | outputDirectory: string | 36 | outputDirectory: string |
34 | } | 37 | } |
38 | |||
39 | // --------------------------------------------------------------------------- | ||
40 | |||
41 | export interface RunnerJobVideoEditionTranscodingPrivatePayload { | ||
42 | videoUUID: string | ||
43 | originalTasks: VideoStudioTaskPayload[] | ||
44 | } | ||
diff --git a/shared/models/runners/runner-job-success-body.model.ts b/shared/models/runners/runner-job-success-body.model.ts index 223b7552d..17e921f69 100644 --- a/shared/models/runners/runner-job-success-body.model.ts +++ b/shared/models/runners/runner-job-success-body.model.ts | |||
@@ -11,7 +11,8 @@ export type RunnerJobSuccessPayload = | |||
11 | VODWebVideoTranscodingSuccess | | 11 | VODWebVideoTranscodingSuccess | |
12 | VODHLSTranscodingSuccess | | 12 | VODHLSTranscodingSuccess | |
13 | VODAudioMergeTranscodingSuccess | | 13 | VODAudioMergeTranscodingSuccess | |
14 | LiveRTMPHLSTranscodingSuccess | 14 | LiveRTMPHLSTranscodingSuccess | |
15 | VideoEditionTranscodingSuccess | ||
15 | 16 | ||
16 | export interface VODWebVideoTranscodingSuccess { | 17 | export interface VODWebVideoTranscodingSuccess { |
17 | videoFile: Blob | string | 18 | videoFile: Blob | string |
@@ -30,6 +31,10 @@ export interface LiveRTMPHLSTranscodingSuccess { | |||
30 | 31 | ||
31 | } | 32 | } |
32 | 33 | ||
34 | export interface VideoEditionTranscodingSuccess { | ||
35 | videoFile: Blob | string | ||
36 | } | ||
37 | |||
33 | export function isWebVideoOrAudioMergeTranscodingPayloadSuccess ( | 38 | export function isWebVideoOrAudioMergeTranscodingPayloadSuccess ( |
34 | payload: RunnerJobSuccessPayload | 39 | payload: RunnerJobSuccessPayload |
35 | ): payload is VODHLSTranscodingSuccess | VODAudioMergeTranscodingSuccess { | 40 | ): payload is VODHLSTranscodingSuccess | VODAudioMergeTranscodingSuccess { |
diff --git a/shared/models/runners/runner-job-type.type.ts b/shared/models/runners/runner-job-type.type.ts index 36d3b9b25..3b997cb6e 100644 --- a/shared/models/runners/runner-job-type.type.ts +++ b/shared/models/runners/runner-job-type.type.ts | |||
@@ -2,4 +2,5 @@ export type RunnerJobType = | |||
2 | 'vod-web-video-transcoding' | | 2 | 'vod-web-video-transcoding' | |
3 | 'vod-hls-transcoding' | | 3 | 'vod-hls-transcoding' | |
4 | 'vod-audio-merge-transcoding' | | 4 | 'vod-audio-merge-transcoding' | |
5 | 'live-rtmp-hls-transcoding' | 5 | 'live-rtmp-hls-transcoding' | |
6 | 'video-edition-transcoding' | ||
diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts index 5d2c10278..4202589f3 100644 --- a/shared/models/server/custom-config.model.ts +++ b/shared/models/server/custom-config.model.ts | |||
@@ -165,6 +165,10 @@ export interface CustomConfig { | |||
165 | 165 | ||
166 | videoStudio: { | 166 | videoStudio: { |
167 | enabled: boolean | 167 | enabled: boolean |
168 | |||
169 | remoteRunners: { | ||
170 | enabled: boolean | ||
171 | } | ||
168 | } | 172 | } |
169 | 173 | ||
170 | import: { | 174 | import: { |
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts index 3fd5bf7f9..22ecee324 100644 --- a/shared/models/server/job.model.ts +++ b/shared/models/server/job.model.ts | |||
@@ -225,6 +225,10 @@ export type VideoStudioTaskWatermarkPayload = { | |||
225 | 225 | ||
226 | options: { | 226 | options: { |
227 | file: string | 227 | file: string |
228 | |||
229 | watermarkSizeRatio: number | ||
230 | horitonzalMarginRatio: number | ||
231 | verticalMarginRatio: number | ||
228 | } | 232 | } |
229 | } | 233 | } |
230 | 234 | ||
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts index 38b9d0385..024ed35bf 100644 --- a/shared/models/server/server-config.model.ts +++ b/shared/models/server/server-config.model.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { VideoPrivacy } from '../videos/video-privacy.enum' | ||
2 | import { ClientScriptJSON } from '../plugins/plugin-package-json.model' | 1 | import { ClientScriptJSON } from '../plugins/plugin-package-json.model' |
3 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' | 2 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' |
3 | import { VideoPrivacy } from '../videos/video-privacy.enum' | ||
4 | import { BroadcastMessageLevel } from './broadcast-message-level.type' | 4 | import { BroadcastMessageLevel } from './broadcast-message-level.type' |
5 | 5 | ||
6 | export interface ServerConfigPlugin { | 6 | export interface ServerConfigPlugin { |
@@ -186,6 +186,10 @@ export interface ServerConfig { | |||
186 | 186 | ||
187 | videoStudio: { | 187 | videoStudio: { |
188 | enabled: boolean | 188 | enabled: boolean |
189 | |||
190 | remoteRunners: { | ||
191 | enabled: boolean | ||
192 | } | ||
189 | } | 193 | } |
190 | 194 | ||
191 | import: { | 195 | import: { |
diff --git a/shared/models/videos/studio/video-studio-create-edit.model.ts b/shared/models/videos/studio/video-studio-create-edit.model.ts index 001d65c90..5e8296dc9 100644 --- a/shared/models/videos/studio/video-studio-create-edit.model.ts +++ b/shared/models/videos/studio/video-studio-create-edit.model.ts | |||
@@ -40,3 +40,21 @@ export interface VideoStudioTaskWatermark { | |||
40 | file: Blob | string | 40 | file: Blob | string |
41 | } | 41 | } |
42 | } | 42 | } |
43 | |||
44 | // --------------------------------------------------------------------------- | ||
45 | |||
46 | export function isVideoStudioTaskIntro (v: VideoStudioTask): v is VideoStudioTaskIntro { | ||
47 | return v.name === 'add-intro' | ||
48 | } | ||
49 | |||
50 | export function isVideoStudioTaskOutro (v: VideoStudioTask): v is VideoStudioTaskOutro { | ||
51 | return v.name === 'add-outro' | ||
52 | } | ||
53 | |||
54 | export function isVideoStudioTaskWatermark (v: VideoStudioTask): v is VideoStudioTaskWatermark { | ||
55 | return v.name === 'add-watermark' | ||
56 | } | ||
57 | |||
58 | export function hasVideoStudioTaskFile (v: VideoStudioTask): v is VideoStudioTaskIntro | VideoStudioTaskOutro | VideoStudioTaskWatermark { | ||
59 | return isVideoStudioTaskIntro(v) || isVideoStudioTaskOutro(v) || isVideoStudioTaskWatermark(v) | ||
60 | } | ||
diff --git a/shared/server-commands/runners/runner-jobs-command.ts b/shared/server-commands/runners/runner-jobs-command.ts index 3b0f84b9d..26dbef77a 100644 --- a/shared/server-commands/runners/runner-jobs-command.ts +++ b/shared/server-commands/runners/runner-jobs-command.ts | |||
@@ -200,7 +200,7 @@ export class RunnerJobsCommand extends AbstractCommand { | |||
200 | }) | 200 | }) |
201 | } | 201 | } |
202 | 202 | ||
203 | getInputFile (options: OverrideCommandOptions & { url: string, jobToken: string, runnerToken: string }) { | 203 | getJobFile (options: OverrideCommandOptions & { url: string, jobToken: string, runnerToken: string }) { |
204 | const { host, protocol, pathname } = new URL(options.url) | 204 | const { host, protocol, pathname } = new URL(options.url) |
205 | 205 | ||
206 | return this.postBodyRequest({ | 206 | return this.postBodyRequest({ |
@@ -249,8 +249,15 @@ export class RunnerJobsCommand extends AbstractCommand { | |||
249 | 249 | ||
250 | const { data } = await this.list({ count: 100 }) | 250 | const { data } = await this.list({ count: 100 }) |
251 | 251 | ||
252 | const allowedStates = new Set<RunnerJobState>([ | ||
253 | RunnerJobState.PENDING, | ||
254 | RunnerJobState.PROCESSING, | ||
255 | RunnerJobState.WAITING_FOR_PARENT_JOB | ||
256 | ]) | ||
257 | |||
252 | for (const job of data) { | 258 | for (const job of data) { |
253 | if (state && job.state.id !== state) continue | 259 | if (state && job.state.id !== state) continue |
260 | else if (allowedStates.has(job.state.id) !== true) continue | ||
254 | 261 | ||
255 | await this.cancelByAdmin({ jobUUID: job.uuid }) | 262 | await this.cancelByAdmin({ jobUUID: job.uuid }) |
256 | } | 263 | } |
diff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.ts index 9a6e413f2..b94bd2625 100644 --- a/shared/server-commands/server/config-command.ts +++ b/shared/server-commands/server/config-command.ts | |||
@@ -195,6 +195,18 @@ export class ConfigCommand extends AbstractCommand { | |||
195 | }) | 195 | }) |
196 | } | 196 | } |
197 | 197 | ||
198 | enableRemoteStudio () { | ||
199 | return this.updateExistingSubConfig({ | ||
200 | newConfig: { | ||
201 | videoStudio: { | ||
202 | remoteRunners: { | ||
203 | enabled: true | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | }) | ||
208 | } | ||
209 | |||
198 | // --------------------------------------------------------------------------- | 210 | // --------------------------------------------------------------------------- |
199 | 211 | ||
200 | enableStudio () { | 212 | enableStudio () { |
@@ -442,7 +454,10 @@ export class ConfigCommand extends AbstractCommand { | |||
442 | } | 454 | } |
443 | }, | 455 | }, |
444 | videoStudio: { | 456 | videoStudio: { |
445 | enabled: false | 457 | enabled: false, |
458 | remoteRunners: { | ||
459 | enabled: false | ||
460 | } | ||
446 | }, | 461 | }, |
447 | import: { | 462 | import: { |
448 | videos: { | 463 | videos: { |