From 5e2afe4290103bf0d54ae7b3e62781f2a00487c9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Aug 2022 15:05:20 +0200 Subject: Limit import depending on transcoding resolutions --- server/helpers/ffmpeg/ffprobe-utils.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'server/helpers/ffmpeg') diff --git a/server/helpers/ffmpeg/ffprobe-utils.ts b/server/helpers/ffmpeg/ffprobe-utils.ts index 7bcd27665..c45f9ec99 100644 --- a/server/helpers/ffmpeg/ffprobe-utils.ts +++ b/server/helpers/ffmpeg/ffprobe-utils.ts @@ -91,11 +91,12 @@ async function getAudioStreamCodec (path: string, existingProbe?: FfprobeData) { // --------------------------------------------------------------------------- function computeResolutionsToTranscode (options: { - inputResolution: number + input: number type: 'vod' | 'live' - includeInputResolution: boolean + includeInput: boolean + strictLower: boolean }) { - const { inputResolution, type, includeInputResolution } = options + const { input, type, includeInput, strictLower } = options const configResolutions = type === 'vod' ? CONFIG.TRANSCODING.RESOLUTIONS @@ -117,13 +118,18 @@ function computeResolutionsToTranscode (options: { ] for (const resolution of availableResolutions) { - if (configResolutions[resolution + 'p'] === true && inputResolution > resolution) { - resolutionsEnabled.add(resolution) - } + // Resolution not enabled + if (configResolutions[resolution + 'p'] !== true) continue + // Too big resolution for input file + if (input < resolution) continue + // We only want lower resolutions than input file + if (strictLower && input === resolution) continue + + resolutionsEnabled.add(resolution) } - if (includeInputResolution) { - resolutionsEnabled.add(inputResolution) + if (includeInput) { + resolutionsEnabled.add(input) } return Array.from(resolutionsEnabled) -- cgit v1.2.3