From ad5db1044c8599eaaaa2a578b350777ae996b068 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Nov 2021 14:35:08 +0100 Subject: Add ability to run transcoding jobs --- shared/models/videos/file/index.ts | 3 + .../videos/file/video-file-metadata.model.ts | 13 +++++ shared/models/videos/file/video-file.model.ts | 21 +++++++ shared/models/videos/file/video-resolution.enum.ts | 11 ++++ shared/models/videos/index.ts | 9 +-- shared/models/videos/transcoding/index.ts | 3 + .../transcoding/video-transcoding-create.model.ts | 3 + .../transcoding/video-transcoding-fps.model.ts | 8 +++ .../videos/transcoding/video-transcoding.model.ts | 64 ++++++++++++++++++++++ shared/models/videos/video-file-metadata.model.ts | 13 ----- shared/models/videos/video-file.model.ts | 21 ------- shared/models/videos/video-resolution.enum.ts | 11 ---- .../videos/video-streaming-playlist.model.ts | 2 +- .../models/videos/video-transcoding-fps.model.ts | 8 --- shared/models/videos/video-transcoding.model.ts | 64 ---------------------- shared/models/videos/video.model.ts | 2 +- 16 files changed, 130 insertions(+), 126 deletions(-) create mode 100644 shared/models/videos/file/index.ts create mode 100644 shared/models/videos/file/video-file-metadata.model.ts create mode 100644 shared/models/videos/file/video-file.model.ts create mode 100644 shared/models/videos/file/video-resolution.enum.ts create mode 100644 shared/models/videos/transcoding/index.ts create mode 100644 shared/models/videos/transcoding/video-transcoding-create.model.ts create mode 100644 shared/models/videos/transcoding/video-transcoding-fps.model.ts create mode 100644 shared/models/videos/transcoding/video-transcoding.model.ts delete mode 100644 shared/models/videos/video-file-metadata.model.ts delete mode 100644 shared/models/videos/video-file.model.ts delete mode 100644 shared/models/videos/video-resolution.enum.ts delete mode 100644 shared/models/videos/video-transcoding-fps.model.ts delete mode 100644 shared/models/videos/video-transcoding.model.ts (limited to 'shared/models/videos') 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 @@ +export * from './video-file-metadata.model' +export * from './video-file.model' +export * from './video-resolution.enum' diff --git a/shared/models/videos/file/video-file-metadata.model.ts b/shared/models/videos/file/video-file-metadata.model.ts new file mode 100644 index 000000000..8f527c0a7 --- /dev/null +++ b/shared/models/videos/file/video-file-metadata.model.ts @@ -0,0 +1,13 @@ +export class VideoFileMetadata { + streams: { [x: string]: any, [x: number]: any }[] + format: { [x: string]: any, [x: number]: any } + chapters: any[] + + constructor (hash: { chapters: any[], format: any, streams: any[] }) { + this.chapters = hash.chapters + this.format = hash.format + this.streams = hash.streams + + delete this.format.filename + } +} diff --git a/shared/models/videos/file/video-file.model.ts b/shared/models/videos/file/video-file.model.ts new file mode 100644 index 000000000..0ea857e7a --- /dev/null +++ b/shared/models/videos/file/video-file.model.ts @@ -0,0 +1,21 @@ +import { VideoConstant } from '../video-constant.model' +import { VideoFileMetadata } from './video-file-metadata.model' +import { VideoResolution } from './video-resolution.enum' + +export interface VideoFile { + resolution: VideoConstant + size: number // Bytes + + torrentUrl: string + torrentDownloadUrl: string + + fileUrl: string + fileDownloadUrl: string + + fps: number + + metadata?: VideoFileMetadata + metadataUrl?: string + + magnetUri: string | null +} diff --git a/shared/models/videos/file/video-resolution.enum.ts b/shared/models/videos/file/video-resolution.enum.ts new file mode 100644 index 000000000..5b48ad353 --- /dev/null +++ b/shared/models/videos/file/video-resolution.enum.ts @@ -0,0 +1,11 @@ +export const enum VideoResolution { + H_NOVIDEO = 0, + H_144P = 144, + H_240P = 240, + H_360P = 360, + H_480P = 480, + H_720P = 720, + H_1080P = 1080, + H_1440P = 1440, + H_4K = 2160 +} 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' export * from './channel' export * from './comment' export * from './live' +export * from './file' export * from './import' export * from './playlist' export * from './rate' +export * from './transcoding' export * from './nsfw-policy.type' @@ -15,14 +17,10 @@ export * from './thumbnail.type' export * from './video-constant.model' export * from './video-create.model' -export * from './video-file-metadata.model' -export * from './video-file.model' - export * from './video-privacy.enum' export * from './video-filter.type' export * from './video-include.enum' export * from './video-rate.type' -export * from './video-resolution.enum' export * from './video-schedule-update.model' export * from './video-sort-field.type' @@ -32,9 +30,6 @@ export * from './video-storage.enum' export * from './video-streaming-playlist.model' export * from './video-streaming-playlist.type' -export * from './video-transcoding.model' -export * from './video-transcoding-fps.model' - export * from './video-update.model' export * from './video.model' 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 @@ +export * from './video-transcoding-create.model' +export * from './video-transcoding-fps.model' +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 @@ +export interface VideoTranscodingCreate { + transcodingType: 'hls' | 'webtorrent' +} diff --git a/shared/models/videos/transcoding/video-transcoding-fps.model.ts b/shared/models/videos/transcoding/video-transcoding-fps.model.ts new file mode 100644 index 000000000..25fc1c2da --- /dev/null +++ b/shared/models/videos/transcoding/video-transcoding-fps.model.ts @@ -0,0 +1,8 @@ +export type VideoTranscodingFPS = { + MIN: number + STANDARD: number[] + HD_STANDARD: number[] + AVERAGE: number + MAX: number + KEEP_ORIGIN_FPS_RESOLUTION_MIN: number +} diff --git a/shared/models/videos/transcoding/video-transcoding.model.ts b/shared/models/videos/transcoding/video-transcoding.model.ts new file mode 100644 index 000000000..3a7fb6472 --- /dev/null +++ b/shared/models/videos/transcoding/video-transcoding.model.ts @@ -0,0 +1,64 @@ +import { VideoResolution } from '../file/video-resolution.enum' + +// Types used by plugins and ffmpeg-utils + +export type EncoderOptionsBuilderParams = { + input: string + + resolution: VideoResolution + + // Could be null for "merge audio" transcoding + fps?: number + + // Could be undefined if we could not get input bitrate (some RTMP streams for example) + inputBitrate: number + inputRatio: number + + // For lives + streamNum?: number +} + +export type EncoderOptionsBuilder = (params: EncoderOptionsBuilderParams) => Promise | EncoderOptions + +export interface EncoderOptions { + copy?: boolean // Copy stream? Default to false + + scaleFilter?: { + name: string + } + + inputOptions?: string[] + outputOptions?: string[] +} + +// All our encoders + +export interface EncoderProfile { + [ profile: string ]: T + + default: T +} + +export type AvailableEncoders = { + available: { + live: { + [ encoder: string ]: EncoderProfile + } + + vod: { + [ encoder: string ]: EncoderProfile + } + } + + encodersToTry: { + vod: { + video: string[] + audio: string[] + } + + live: { + video: string[] + audio: string[] + } + } +} diff --git a/shared/models/videos/video-file-metadata.model.ts b/shared/models/videos/video-file-metadata.model.ts deleted file mode 100644 index 8f527c0a7..000000000 --- a/shared/models/videos/video-file-metadata.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -export class VideoFileMetadata { - streams: { [x: string]: any, [x: number]: any }[] - format: { [x: string]: any, [x: number]: any } - chapters: any[] - - constructor (hash: { chapters: any[], format: any, streams: any[] }) { - this.chapters = hash.chapters - this.format = hash.format - this.streams = hash.streams - - delete this.format.filename - } -} diff --git a/shared/models/videos/video-file.model.ts b/shared/models/videos/video-file.model.ts deleted file mode 100644 index 28fce0aaf..000000000 --- a/shared/models/videos/video-file.model.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { VideoConstant } from './video-constant.model' -import { VideoFileMetadata } from './video-file-metadata.model' -import { VideoResolution } from './video-resolution.enum' - -export interface VideoFile { - resolution: VideoConstant - size: number // Bytes - - torrentUrl: string - torrentDownloadUrl: string - - fileUrl: string - fileDownloadUrl: string - - fps: number - - metadata?: VideoFileMetadata - metadataUrl?: string - - magnetUri: string | null -} diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts deleted file mode 100644 index 5b48ad353..000000000 --- a/shared/models/videos/video-resolution.enum.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const enum VideoResolution { - H_NOVIDEO = 0, - H_144P = 144, - H_240P = 240, - H_360P = 360, - H_480P = 480, - H_720P = 720, - H_1080P = 1080, - H_1440P = 1440, - H_4K = 2160 -} 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 @@ import { VideoStreamingPlaylistType } from './video-streaming-playlist.type' -import { VideoFile } from './video-file.model' +import { VideoFile } from './file' export interface VideoStreamingPlaylist { id: number diff --git a/shared/models/videos/video-transcoding-fps.model.ts b/shared/models/videos/video-transcoding-fps.model.ts deleted file mode 100644 index 25fc1c2da..000000000 --- a/shared/models/videos/video-transcoding-fps.model.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type VideoTranscodingFPS = { - MIN: number - STANDARD: number[] - HD_STANDARD: number[] - AVERAGE: number - MAX: number - KEEP_ORIGIN_FPS_RESOLUTION_MIN: number -} diff --git a/shared/models/videos/video-transcoding.model.ts b/shared/models/videos/video-transcoding.model.ts deleted file mode 100644 index 83b8e98a0..000000000 --- a/shared/models/videos/video-transcoding.model.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { VideoResolution } from './video-resolution.enum' - -// Types used by plugins and ffmpeg-utils - -export type EncoderOptionsBuilderParams = { - input: string - - resolution: VideoResolution - - // Could be null for "merge audio" transcoding - fps?: number - - // Could be undefined if we could not get input bitrate (some RTMP streams for example) - inputBitrate: number - inputRatio: number - - // For lives - streamNum?: number -} - -export type EncoderOptionsBuilder = (params: EncoderOptionsBuilderParams) => Promise | EncoderOptions - -export interface EncoderOptions { - copy?: boolean // Copy stream? Default to false - - scaleFilter?: { - name: string - } - - inputOptions?: string[] - outputOptions?: string[] -} - -// All our encoders - -export interface EncoderProfile { - [ profile: string ]: T - - default: T -} - -export type AvailableEncoders = { - available: { - live: { - [ encoder: string ]: EncoderProfile - } - - vod: { - [ encoder: string ]: EncoderProfile - } - } - - encodersToTry: { - vod: { - video: string[] - audio: string[] - } - - live: { - video: string[] - audio: string[] - } - } -} 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 @@ import { Account, AccountSummary } from '../actors' import { VideoChannel, VideoChannelSummary } from './channel/video-channel.model' +import { VideoFile } from './file' import { VideoConstant } from './video-constant.model' -import { VideoFile } from './video-file.model' import { VideoPrivacy } from './video-privacy.enum' import { VideoScheduleUpdate } from './video-schedule-update.model' import { VideoState } from './video-state.enum' -- cgit v1.2.3