aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-01-28 15:52:44 +0100
committerChocobozzz <me@florianbigard.com>2021-01-28 15:55:39 +0100
commit1896bca09e088b0da9d5e845407ecebae330618c (patch)
tree56041c445c0cd49aca536d0fd6b586730f4d341e /shared/models
parent529b37527cff5203a0689a15ce73dcee6e1eece2 (diff)
downloadPeerTube-1896bca09e088b0da9d5e845407ecebae330618c.tar.gz
PeerTube-1896bca09e088b0da9d5e845407ecebae330618c.tar.zst
PeerTube-1896bca09e088b0da9d5e845407ecebae330618c.zip
Support transcoding options/encoders by plugins
Diffstat (limited to 'shared/models')
-rw-r--r--shared/models/plugins/index.ts1
-rw-r--r--shared/models/plugins/plugin-transcoding-manager.model.ts11
-rw-r--r--shared/models/server/custom-config.model.ts4
-rw-r--r--shared/models/server/server-config.model.ts6
-rw-r--r--shared/models/videos/index.ts1
-rw-r--r--shared/models/videos/video-transcoding.model.ts48
6 files changed, 71 insertions, 0 deletions
diff --git a/shared/models/plugins/index.ts b/shared/models/plugins/index.ts
index 83ed6f583..96621460a 100644
--- a/shared/models/plugins/index.ts
+++ b/shared/models/plugins/index.ts
@@ -11,6 +11,7 @@ export * from './plugin-package-json.model'
11export * from './plugin-playlist-privacy-manager.model' 11export * from './plugin-playlist-privacy-manager.model'
12export * from './plugin-settings-manager.model' 12export * from './plugin-settings-manager.model'
13export * from './plugin-storage-manager.model' 13export * from './plugin-storage-manager.model'
14export * from './plugin-transcoding-manager.model'
14export * from './plugin-translation.model' 15export * from './plugin-translation.model'
15export * from './plugin-video-category-manager.model' 16export * from './plugin-video-category-manager.model'
16export * from './plugin-video-language-manager.model' 17export * from './plugin-video-language-manager.model'
diff --git a/shared/models/plugins/plugin-transcoding-manager.model.ts b/shared/models/plugins/plugin-transcoding-manager.model.ts
new file mode 100644
index 000000000..ff89687e9
--- /dev/null
+++ b/shared/models/plugins/plugin-transcoding-manager.model.ts
@@ -0,0 +1,11 @@
1import { EncoderOptionsBuilder } from '../videos/video-transcoding.model'
2
3export interface PluginTranscodingManager {
4 addLiveProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean
5
6 addVODProfile (encoder: string, profile: string, builder: EncoderOptionsBuilder): boolean
7
8 addLiveEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void
9
10 addVODEncoderPriority (streamType: 'audio' | 'video', encoder: string, priority: number): void
11}
diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts
index a57237414..d23b8abef 100644
--- a/shared/models/server/custom-config.model.ts
+++ b/shared/models/server/custom-config.model.ts
@@ -87,6 +87,9 @@ export interface CustomConfig {
87 allowAudioFiles: boolean 87 allowAudioFiles: boolean
88 88
89 threads: number 89 threads: number
90
91 profile: string
92
90 resolutions: ConfigResolutions & { '0p': boolean } 93 resolutions: ConfigResolutions & { '0p': boolean }
91 94
92 webtorrent: { 95 webtorrent: {
@@ -110,6 +113,7 @@ export interface CustomConfig {
110 transcoding: { 113 transcoding: {
111 enabled: boolean 114 enabled: boolean
112 threads: number 115 threads: number
116 profile: string
113 resolutions: ConfigResolutions 117 resolutions: ConfigResolutions
114 } 118 }
115 } 119 }
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts
index 47d0e623b..efde4ad9d 100644
--- a/shared/models/server/server-config.model.ts
+++ b/shared/models/server/server-config.model.ts
@@ -96,6 +96,9 @@ export interface ServerConfig {
96 } 96 }
97 97
98 enabledResolutions: number[] 98 enabledResolutions: number[]
99
100 profile: string
101 availableProfiles: string[]
99 } 102 }
100 103
101 live: { 104 live: {
@@ -110,6 +113,9 @@ export interface ServerConfig {
110 enabled: boolean 113 enabled: boolean
111 114
112 enabledResolutions: number[] 115 enabledResolutions: number[]
116
117 profile: string
118 availableProfiles: string[]
113 } 119 }
114 120
115 rtmp: { 121 rtmp: {
diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts
index abf144f23..fac3e0b2f 100644
--- a/shared/models/videos/index.ts
+++ b/shared/models/videos/index.ts
@@ -34,6 +34,7 @@ export * from './video-state.enum'
34export * from './video-streaming-playlist.model' 34export * from './video-streaming-playlist.model'
35export * from './video-streaming-playlist.type' 35export * from './video-streaming-playlist.type'
36 36
37export * from './video-transcoding.model'
37export * from './video-transcoding-fps.model' 38export * from './video-transcoding-fps.model'
38 39
39export * from './video-update.model' 40export * from './video-update.model'
diff --git a/shared/models/videos/video-transcoding.model.ts b/shared/models/videos/video-transcoding.model.ts
new file mode 100644
index 000000000..06b555c16
--- /dev/null
+++ b/shared/models/videos/video-transcoding.model.ts
@@ -0,0 +1,48 @@
1import { VideoResolution } from './video-resolution.enum'
2
3// Types used by plugins and ffmpeg-utils
4
5export type EncoderOptionsBuilder = (params: {
6 input: string
7 resolution: VideoResolution
8 fps?: number
9 streamNum?: number
10}) => Promise<EncoderOptions> | EncoderOptions
11
12export interface EncoderOptions {
13 copy?: boolean // Copy stream? Default to false
14
15 outputOptions: string[]
16}
17
18// All our encoders
19
20export interface EncoderProfile <T> {
21 [ profile: string ]: T
22
23 default: T
24}
25
26export type AvailableEncoders = {
27 available: {
28 live: {
29 [ encoder: string ]: EncoderProfile<EncoderOptionsBuilder>
30 }
31
32 vod: {
33 [ encoder: string ]: EncoderProfile<EncoderOptionsBuilder>
34 }
35 }
36
37 encodersToTry: {
38 vod: {
39 video: string[]
40 audio: string[]
41 }
42
43 live: {
44 video: string[]
45 audio: string[]
46 }
47 }
48}