diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-18 14:35:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-18 15:20:57 +0100 |
commit | ad5db1044c8599eaaaa2a578b350777ae996b068 (patch) | |
tree | 3e003cccf021152405d49b21c6c91b703c8ae96c /shared | |
parent | b46cf4b920984492df598c1b61179acfc7f6f22e (diff) | |
download | PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.tar.gz PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.tar.zst PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.zip |
Add ability to run transcoding jobs
Diffstat (limited to 'shared')
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' |
23 | import { buildAbsoluteFixturePath, wait } from '../miscs' | 24 | import { buildAbsoluteFixturePath, wait } from '../miscs' |
24 | import { unwrapBody } from '../requests' | 25 | import { 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 @@ | |||
1 | import { EncoderOptionsBuilder } from '../../../videos/video-transcoding.model' | 1 | import { EncoderOptionsBuilder } from '../../../videos/transcoding' |
2 | 2 | ||
3 | export interface PluginTranscodingManager { | 3 | export 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 @@ | |||
1 | import { ContextType } from '../activitypub/context' | 1 | import { ContextType } from '../activitypub/context' |
2 | import { VideoResolution } from '../videos/video-resolution.enum' | 2 | import { VideoResolution } from '../videos/file/video-resolution.enum' |
3 | import { SendEmailOptions } from './emailer.model' | 3 | import { SendEmailOptions } from './emailer.model' |
4 | 4 | ||
5 | export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused' | 5 | export 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 @@ | |||
1 | export * from './video-file-metadata.model' | ||
2 | export * from './video-file.model' | ||
3 | export * 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 @@ | |||
1 | import { VideoConstant } from './video-constant.model' | 1 | import { VideoConstant } from '../video-constant.model' |
2 | import { VideoFileMetadata } from './video-file-metadata.model' | 2 | import { VideoFileMetadata } from './video-file-metadata.model' |
3 | import { VideoResolution } from './video-resolution.enum' | 3 | import { 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' | |||
4 | export * from './channel' | 4 | export * from './channel' |
5 | export * from './comment' | 5 | export * from './comment' |
6 | export * from './live' | 6 | export * from './live' |
7 | export * from './file' | ||
7 | export * from './import' | 8 | export * from './import' |
8 | export * from './playlist' | 9 | export * from './playlist' |
9 | export * from './rate' | 10 | export * from './rate' |
11 | export * from './transcoding' | ||
10 | 12 | ||
11 | export * from './nsfw-policy.type' | 13 | export * from './nsfw-policy.type' |
12 | 14 | ||
@@ -15,14 +17,10 @@ export * from './thumbnail.type' | |||
15 | export * from './video-constant.model' | 17 | export * from './video-constant.model' |
16 | export * from './video-create.model' | 18 | export * from './video-create.model' |
17 | 19 | ||
18 | export * from './video-file-metadata.model' | ||
19 | export * from './video-file.model' | ||
20 | |||
21 | export * from './video-privacy.enum' | 20 | export * from './video-privacy.enum' |
22 | export * from './video-filter.type' | 21 | export * from './video-filter.type' |
23 | export * from './video-include.enum' | 22 | export * from './video-include.enum' |
24 | export * from './video-rate.type' | 23 | export * from './video-rate.type' |
25 | export * from './video-resolution.enum' | ||
26 | 24 | ||
27 | export * from './video-schedule-update.model' | 25 | export * from './video-schedule-update.model' |
28 | export * from './video-sort-field.type' | 26 | export * from './video-sort-field.type' |
@@ -32,9 +30,6 @@ export * from './video-storage.enum' | |||
32 | export * from './video-streaming-playlist.model' | 30 | export * from './video-streaming-playlist.model' |
33 | export * from './video-streaming-playlist.type' | 31 | export * from './video-streaming-playlist.type' |
34 | 32 | ||
35 | export * from './video-transcoding.model' | ||
36 | export * from './video-transcoding-fps.model' | ||
37 | |||
38 | export * from './video-update.model' | 33 | export * from './video-update.model' |
39 | export * from './video.model' | 34 | export * from './video.model' |
40 | export * from './video-create-result.model' | 35 | export * 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 @@ | |||
1 | export * from './video-transcoding-create.model' | ||
2 | export * from './video-transcoding-fps.model' | ||
3 | export * 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 @@ | |||
1 | export 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 @@ | |||
1 | import { VideoResolution } from './video-resolution.enum' | 1 | import { 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 @@ | |||
1 | import { VideoStreamingPlaylistType } from './video-streaming-playlist.type' | 1 | import { VideoStreamingPlaylistType } from './video-streaming-playlist.type' |
2 | import { VideoFile } from './video-file.model' | 2 | import { VideoFile } from './file' |
3 | 3 | ||
4 | export interface VideoStreamingPlaylist { | 4 | export 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 @@ | |||
1 | import { Account, AccountSummary } from '../actors' | 1 | import { Account, AccountSummary } from '../actors' |
2 | import { VideoChannel, VideoChannelSummary } from './channel/video-channel.model' | 2 | import { VideoChannel, VideoChannelSummary } from './channel/video-channel.model' |
3 | import { VideoFile } from './file' | ||
3 | import { VideoConstant } from './video-constant.model' | 4 | import { VideoConstant } from './video-constant.model' |
4 | import { VideoFile } from './video-file.model' | ||
5 | import { VideoPrivacy } from './video-privacy.enum' | 5 | import { VideoPrivacy } from './video-privacy.enum' |
6 | import { VideoScheduleUpdate } from './video-schedule-update.model' | 6 | import { VideoScheduleUpdate } from './video-schedule-update.model' |
7 | import { VideoState } from './video-state.enum' | 7 | import { VideoState } from './video-state.enum' |