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 --- server/helpers/custom-validators/video-transcoding.ts | 12 ++++++++++++ server/helpers/ffprobe-utils.ts | 6 +++--- server/helpers/webtorrent.ts | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 server/helpers/custom-validators/video-transcoding.ts (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/video-transcoding.ts b/server/helpers/custom-validators/video-transcoding.ts new file mode 100644 index 000000000..cf792f996 --- /dev/null +++ b/server/helpers/custom-validators/video-transcoding.ts @@ -0,0 +1,12 @@ +import { exists } from './misc' + +function isValidCreateTranscodingType (value: any) { + return exists(value) && + (value === 'hls' || value === 'webtorrent') +} + +// --------------------------------------------------------------------------- + +export { + isValidCreateTranscodingType +} diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts index 907f13651..e15628e2a 100644 --- a/server/helpers/ffprobe-utils.ts +++ b/server/helpers/ffprobe-utils.ts @@ -206,7 +206,7 @@ async function getVideoStreamFromFile (path: string, existingProbe?: FfprobeData return metadata.streams.find(s => s.codec_type === 'video') || null } -function computeResolutionsToTranscode (videoFileResolution: number, type: 'vod' | 'live') { +function computeLowerResolutionsToTranscode (videoFileResolution: number, type: 'vod' | 'live') { const configResolutions = type === 'vod' ? CONFIG.TRANSCODING.RESOLUTIONS : CONFIG.LIVE.TRANSCODING.RESOLUTIONS @@ -214,7 +214,7 @@ function computeResolutionsToTranscode (videoFileResolution: number, type: 'vod' const resolutionsEnabled: number[] = [] // Put in the order we want to proceed jobs - const resolutions = [ + const resolutions: VideoResolution[] = [ VideoResolution.H_NOVIDEO, VideoResolution.H_480P, VideoResolution.H_360P, @@ -327,7 +327,7 @@ export { getVideoFileFPS, ffprobePromise, getClosestFramerateStandard, - computeResolutionsToTranscode, + computeLowerResolutionsToTranscode, getVideoFileBitrate, canDoQuickTranscode, canDoQuickVideoTranscode, diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 5e1ea6198..c75c058e4 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts @@ -100,7 +100,7 @@ function createTorrentAndSetInfoHash (videoOrPlaylist: MVideo | MStreamingPlayli urlList: buildUrlList(video, videoFile) } - return VideoPathManager.Instance.makeAvailableVideoFile(videoOrPlaylist, videoFile, async videoPath => { + return VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(videoOrPlaylist), async videoPath => { const torrentContent = await createTorrentPromise(videoPath, options) const torrentFilename = generateTorrentFileName(videoOrPlaylist, videoFile.resolution) -- cgit v1.2.3