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 /server/controllers/api/videos/studio.ts | |
parent | 6a4905602636afd6650c9e6f4d0fcc2105d91100 (diff) | |
download | PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.tar.gz PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.tar.zst PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.zip |
Support studio transcoding in peertube runner
Diffstat (limited to 'server/controllers/api/videos/studio.ts')
-rw-r--r-- | server/controllers/api/videos/studio.ts | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/server/controllers/api/videos/studio.ts b/server/controllers/api/videos/studio.ts index 2ccb2fb89..7c31dfd2b 100644 --- a/server/controllers/api/videos/studio.ts +++ b/server/controllers/api/videos/studio.ts | |||
@@ -1,12 +1,10 @@ | |||
1 | import Bluebird from 'bluebird' | 1 | import Bluebird from 'bluebird' |
2 | import express from 'express' | 2 | import express from 'express' |
3 | import { move } from 'fs-extra' | 3 | import { move } from 'fs-extra' |
4 | import { basename, join } from 'path' | 4 | import { basename } from 'path' |
5 | import { createAnyReqFiles } from '@server/helpers/express-utils' | 5 | import { createAnyReqFiles } from '@server/helpers/express-utils' |
6 | import { CONFIG } from '@server/initializers/config' | 6 | import { MIMETYPES, VIDEO_FILTERS } from '@server/initializers/constants' |
7 | import { MIMETYPES } from '@server/initializers/constants' | 7 | import { buildTaskFileFieldname, createVideoStudioJob, getStudioTaskFilePath, getTaskFileFromReq } from '@server/lib/video-studio' |
8 | import { JobQueue } from '@server/lib/job-queue' | ||
9 | import { buildTaskFileFieldname, getTaskFileFromReq } from '@server/lib/video-studio' | ||
10 | import { | 8 | import { |
11 | HttpStatusCode, | 9 | HttpStatusCode, |
12 | VideoState, | 10 | VideoState, |
@@ -75,7 +73,11 @@ async function createEditionTasks (req: express.Request, res: express.Response) | |||
75 | tasks: await Bluebird.mapSeries(body.tasks, (t, i) => buildTaskPayload(t, i, files)) | 73 | tasks: await Bluebird.mapSeries(body.tasks, (t, i) => buildTaskPayload(t, i, files)) |
76 | } | 74 | } |
77 | 75 | ||
78 | JobQueue.Instance.createJobAsync({ type: 'video-studio-edition', payload }) | 76 | await createVideoStudioJob({ |
77 | user: res.locals.oauth.token.User, | ||
78 | payload, | ||
79 | video | ||
80 | }) | ||
79 | 81 | ||
80 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) | 82 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) |
81 | } | 83 | } |
@@ -124,13 +126,16 @@ async function buildWatermarkTask (task: VideoStudioTaskWatermark, indice: numbe | |||
124 | return { | 126 | return { |
125 | name: task.name, | 127 | name: task.name, |
126 | options: { | 128 | options: { |
127 | file: destination | 129 | file: destination, |
130 | watermarkSizeRatio: VIDEO_FILTERS.WATERMARK.SIZE_RATIO, | ||
131 | horitonzalMarginRatio: VIDEO_FILTERS.WATERMARK.HORIZONTAL_MARGIN_RATIO, | ||
132 | verticalMarginRatio: VIDEO_FILTERS.WATERMARK.VERTICAL_MARGIN_RATIO | ||
128 | } | 133 | } |
129 | } | 134 | } |
130 | } | 135 | } |
131 | 136 | ||
132 | async function moveStudioFileToPersistentTMP (file: string) { | 137 | async function moveStudioFileToPersistentTMP (file: string) { |
133 | const destination = join(CONFIG.STORAGE.TMP_PERSISTENT_DIR, basename(file)) | 138 | const destination = getStudioTaskFilePath(basename(file)) |
134 | 139 | ||
135 | await move(file, destination) | 140 | await move(file, destination) |
136 | 141 | ||