aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-18 14:35:08 +0100
committerChocobozzz <me@florianbigard.com>2021-11-18 15:20:57 +0100
commitad5db1044c8599eaaaa2a578b350777ae996b068 (patch)
tree3e003cccf021152405d49b21c6c91b703c8ae96c /shared
parentb46cf4b920984492df598c1b61179acfc7f6f22e (diff)
downloadPeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.tar.gz
PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.tar.zst
PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.zip
Add ability to run transcoding jobs
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/server/jobs-command.ts15
-rw-r--r--shared/extra-utils/videos/videos-command.ts21
-rw-r--r--shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts2
-rw-r--r--shared/models/server/job.model.ts4
-rw-r--r--shared/models/users/user-right.enum.ts3
-rw-r--r--shared/models/videos/file/index.ts3
-rw-r--r--shared/models/videos/file/video-file-metadata.model.ts (renamed from shared/models/videos/video-file-metadata.model.ts)0
-rw-r--r--shared/models/videos/file/video-file.model.ts (renamed from shared/models/videos/video-file.model.ts)2
-rw-r--r--shared/models/videos/file/video-resolution.enum.ts (renamed from shared/models/videos/video-resolution.enum.ts)0
-rw-r--r--shared/models/videos/index.ts9
-rw-r--r--shared/models/videos/transcoding/index.ts3
-rw-r--r--shared/models/videos/transcoding/video-transcoding-create.model.ts3
-rw-r--r--shared/models/videos/transcoding/video-transcoding-fps.model.ts (renamed from shared/models/videos/video-transcoding-fps.model.ts)0
-rw-r--r--shared/models/videos/transcoding/video-transcoding.model.ts (renamed from shared/models/videos/video-transcoding.model.ts)2
-rw-r--r--shared/models/videos/video-streaming-playlist.model.ts2
-rw-r--r--shared/models/videos/video.model.ts2
16 files changed, 56 insertions, 15 deletions
diff --git a/shared/extra-utils/server/jobs-command.ts b/shared/extra-utils/server/jobs-command.ts
index f28397816..6636e7e4d 100644
--- a/shared/extra-utils/server/jobs-command.ts
+++ b/shared/extra-utils/server/jobs-command.ts
@@ -36,6 +36,21 @@ export class JobsCommand extends AbstractCommand {
36 }) 36 })
37 } 37 }
38 38
39 listFailed (options: OverrideCommandOptions & {
40 jobType?: JobType
41 }) {
42 const path = this.buildJobsUrl('failed')
43
44 return this.getRequestBody<ResultList<Job>>({
45 ...options,
46
47 path,
48 query: { start: 0, count: 50 },
49 implicitToken: true,
50 defaultExpectedStatus: HttpStatusCode.OK_200
51 })
52 }
53
39 private buildJobsUrl (state?: JobState) { 54 private buildJobsUrl (state?: JobState) {
40 let path = '/api/v1/jobs' 55 let path = '/api/v1/jobs'
41 56
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts
index 13a7d0e1c..7ec9c3647 100644
--- a/shared/extra-utils/videos/videos-command.ts
+++ b/shared/extra-utils/videos/videos-command.ts
@@ -18,7 +18,8 @@ import {
18 VideoDetails, 18 VideoDetails,
19 VideoFileMetadata, 19 VideoFileMetadata,
20 VideoPrivacy, 20 VideoPrivacy,
21 VideosCommonQuery 21 VideosCommonQuery,
22 VideoTranscodingCreate
22} from '@shared/models' 23} from '@shared/models'
23import { buildAbsoluteFixturePath, wait } from '../miscs' 24import { buildAbsoluteFixturePath, wait } from '../miscs'
24import { unwrapBody } from '../requests' 25import { unwrapBody } from '../requests'
@@ -630,6 +631,24 @@ export class VideosCommand extends AbstractCommand {
630 }) 631 })
631 } 632 }
632 633
634 runTranscoding (options: OverrideCommandOptions & {
635 videoId: number | string
636 transcodingType: 'hls' | 'webtorrent'
637 }) {
638 const path = '/api/v1/videos/' + options.videoId + '/transcoding'
639
640 const fields: VideoTranscodingCreate = pick(options, [ 'transcodingType' ])
641
642 return this.postBodyRequest({
643 ...options,
644
645 path,
646 fields,
647 implicitToken: true,
648 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
649 })
650 }
651
633 // --------------------------------------------------------------------------- 652 // ---------------------------------------------------------------------------
634 653
635 private buildListQuery (options: VideosCommonQuery) { 654 private buildListQuery (options: VideosCommonQuery) {
diff --git a/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts b/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts
index a0422a460..b6fb46ba0 100644
--- a/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts
+++ b/shared/models/plugins/server/managers/plugin-transcoding-manager.model.ts
@@ -1,4 +1,4 @@
1import { EncoderOptionsBuilder } from '../../../videos/video-transcoding.model' 1import { EncoderOptionsBuilder } from '../../../videos/transcoding'
2 2
3export interface PluginTranscodingManager { 3export interface PluginTranscodingManager {
4 addLiveProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean 4 addLiveProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts
index 6da2753b3..ecc960da5 100644
--- a/shared/models/server/job.model.ts
+++ b/shared/models/server/job.model.ts
@@ -1,5 +1,5 @@
1import { ContextType } from '../activitypub/context' 1import { ContextType } from '../activitypub/context'
2import { VideoResolution } from '../videos/video-resolution.enum' 2import { VideoResolution } from '../videos/file/video-resolution.enum'
3import { SendEmailOptions } from './emailer.model' 3import { SendEmailOptions } from './emailer.model'
4 4
5export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused' 5export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused'
@@ -106,6 +106,8 @@ export interface HLSTranscodingPayload extends BaseTranscodingPayload {
106 isPortraitMode?: boolean 106 isPortraitMode?: boolean
107 resolution: VideoResolution 107 resolution: VideoResolution
108 copyCodecs: boolean 108 copyCodecs: boolean
109
110 autoDeleteWebTorrentIfNeeded: boolean
109 isMaxQuality: boolean 111 isMaxQuality: boolean
110} 112}
111 113
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts
index 96bccaf2f..6415ca6f2 100644
--- a/shared/models/users/user-right.enum.ts
+++ b/shared/models/users/user-right.enum.ts
@@ -40,5 +40,6 @@ export const enum UserRight {
40 40
41 MANAGE_VIDEOS_REDUNDANCIES, 41 MANAGE_VIDEOS_REDUNDANCIES,
42 42
43 MANAGE_VIDEO_FILES 43 MANAGE_VIDEO_FILES,
44 RUN_VIDEO_TRANSCODING
44} 45}
diff --git a/shared/models/videos/file/index.ts b/shared/models/videos/file/index.ts
new file mode 100644
index 000000000..78a784a3c
--- /dev/null
+++ b/shared/models/videos/file/index.ts
@@ -0,0 +1,3 @@
1export * from './video-file-metadata.model'
2export * from './video-file.model'
3export * from './video-resolution.enum'
diff --git a/shared/models/videos/video-file-metadata.model.ts b/shared/models/videos/file/video-file-metadata.model.ts
index 8f527c0a7..8f527c0a7 100644
--- a/shared/models/videos/video-file-metadata.model.ts
+++ b/shared/models/videos/file/video-file-metadata.model.ts
diff --git a/shared/models/videos/video-file.model.ts b/shared/models/videos/file/video-file.model.ts
index 28fce0aaf..0ea857e7a 100644
--- a/shared/models/videos/video-file.model.ts
+++ b/shared/models/videos/file/video-file.model.ts
@@ -1,4 +1,4 @@
1import { VideoConstant } from './video-constant.model' 1import { VideoConstant } from '../video-constant.model'
2import { VideoFileMetadata } from './video-file-metadata.model' 2import { VideoFileMetadata } from './video-file-metadata.model'
3import { VideoResolution } from './video-resolution.enum' 3import { VideoResolution } from './video-resolution.enum'
4 4
diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/file/video-resolution.enum.ts
index 5b48ad353..5b48ad353 100644
--- a/shared/models/videos/video-resolution.enum.ts
+++ b/shared/models/videos/file/video-resolution.enum.ts
diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts
index 3d3eedcc6..67614efc9 100644
--- a/shared/models/videos/index.ts
+++ b/shared/models/videos/index.ts
@@ -4,9 +4,11 @@ export * from './change-ownership'
4export * from './channel' 4export * from './channel'
5export * from './comment' 5export * from './comment'
6export * from './live' 6export * from './live'
7export * from './file'
7export * from './import' 8export * from './import'
8export * from './playlist' 9export * from './playlist'
9export * from './rate' 10export * from './rate'
11export * from './transcoding'
10 12
11export * from './nsfw-policy.type' 13export * from './nsfw-policy.type'
12 14
@@ -15,14 +17,10 @@ export * from './thumbnail.type'
15export * from './video-constant.model' 17export * from './video-constant.model'
16export * from './video-create.model' 18export * from './video-create.model'
17 19
18export * from './video-file-metadata.model'
19export * from './video-file.model'
20
21export * from './video-privacy.enum' 20export * from './video-privacy.enum'
22export * from './video-filter.type' 21export * from './video-filter.type'
23export * from './video-include.enum' 22export * from './video-include.enum'
24export * from './video-rate.type' 23export * from './video-rate.type'
25export * from './video-resolution.enum'
26 24
27export * from './video-schedule-update.model' 25export * from './video-schedule-update.model'
28export * from './video-sort-field.type' 26export * from './video-sort-field.type'
@@ -32,9 +30,6 @@ export * from './video-storage.enum'
32export * from './video-streaming-playlist.model' 30export * from './video-streaming-playlist.model'
33export * from './video-streaming-playlist.type' 31export * from './video-streaming-playlist.type'
34 32
35export * from './video-transcoding.model'
36export * from './video-transcoding-fps.model'
37
38export * from './video-update.model' 33export * from './video-update.model'
39export * from './video.model' 34export * from './video.model'
40export * from './video-create-result.model' 35export * from './video-create-result.model'
diff --git a/shared/models/videos/transcoding/index.ts b/shared/models/videos/transcoding/index.ts
new file mode 100644
index 000000000..14472d900
--- /dev/null
+++ b/shared/models/videos/transcoding/index.ts
@@ -0,0 +1,3 @@
1export * from './video-transcoding-create.model'
2export * from './video-transcoding-fps.model'
3export * from './video-transcoding.model'
diff --git a/shared/models/videos/transcoding/video-transcoding-create.model.ts b/shared/models/videos/transcoding/video-transcoding-create.model.ts
new file mode 100644
index 000000000..aeb393e57
--- /dev/null
+++ b/shared/models/videos/transcoding/video-transcoding-create.model.ts
@@ -0,0 +1,3 @@
1export interface VideoTranscodingCreate {
2 transcodingType: 'hls' | 'webtorrent'
3}
diff --git a/shared/models/videos/video-transcoding-fps.model.ts b/shared/models/videos/transcoding/video-transcoding-fps.model.ts
index 25fc1c2da..25fc1c2da 100644
--- a/shared/models/videos/video-transcoding-fps.model.ts
+++ b/shared/models/videos/transcoding/video-transcoding-fps.model.ts
diff --git a/shared/models/videos/video-transcoding.model.ts b/shared/models/videos/transcoding/video-transcoding.model.ts
index 83b8e98a0..3a7fb6472 100644
--- a/shared/models/videos/video-transcoding.model.ts
+++ b/shared/models/videos/transcoding/video-transcoding.model.ts
@@ -1,4 +1,4 @@
1import { VideoResolution } from './video-resolution.enum' 1import { VideoResolution } from '../file/video-resolution.enum'
2 2
3// Types used by plugins and ffmpeg-utils 3// Types used by plugins and ffmpeg-utils
4 4
diff --git a/shared/models/videos/video-streaming-playlist.model.ts b/shared/models/videos/video-streaming-playlist.model.ts
index b547a0ac7..11919a4ee 100644
--- a/shared/models/videos/video-streaming-playlist.model.ts
+++ b/shared/models/videos/video-streaming-playlist.model.ts
@@ -1,5 +1,5 @@
1import { VideoStreamingPlaylistType } from './video-streaming-playlist.type' 1import { VideoStreamingPlaylistType } from './video-streaming-playlist.type'
2import { VideoFile } from './video-file.model' 2import { VideoFile } from './file'
3 3
4export interface VideoStreamingPlaylist { 4export interface VideoStreamingPlaylist {
5 id: number 5 id: number
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts
index 8d223cded..f98eed012 100644
--- a/shared/models/videos/video.model.ts
+++ b/shared/models/videos/video.model.ts
@@ -1,7 +1,7 @@
1import { Account, AccountSummary } from '../actors' 1import { Account, AccountSummary } from '../actors'
2import { VideoChannel, VideoChannelSummary } from './channel/video-channel.model' 2import { VideoChannel, VideoChannelSummary } from './channel/video-channel.model'
3import { VideoFile } from './file'
3import { VideoConstant } from './video-constant.model' 4import { VideoConstant } from './video-constant.model'
4import { VideoFile } from './video-file.model'
5import { VideoPrivacy } from './video-privacy.enum' 5import { VideoPrivacy } from './video-privacy.enum'
6import { VideoScheduleUpdate } from './video-schedule-update.model' 6import { VideoScheduleUpdate } from './video-schedule-update.model'
7import { VideoState } from './video-state.enum' 7import { VideoState } from './video-state.enum'