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/lib/job-queue/handlers/video-import.ts | 9 +++++++-- server/lib/job-queue/handlers/video-transcoding.ts | 2 +- server/lib/live/live-manager.ts | 4 ++-- server/lib/transcoding/transcoding.ts | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) (limited to 'server/lib') diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 40804e82e..4cde26aef 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts @@ -2,6 +2,7 @@ import { Job } from 'bull' import { move, remove, stat } from 'fs-extra' import { retryTransactionWrapper } from '@server/helpers/database-utils' import { YoutubeDLWrapper } from '@server/helpers/youtube-dl' +import { CONFIG } from '@server/initializers/config' import { isPostImportVideoAccepted } from '@server/lib/moderation' import { generateWebTorrentVideoFilename } from '@server/lib/paths' import { Hooks } from '@server/lib/plugins/hooks' @@ -25,7 +26,7 @@ import { VideoResolution, VideoState } from '@shared/models' -import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, getVideoStreamDimensionsInfo } from '../../../helpers/ffmpeg' +import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamDuration, getVideoStreamFPS } from '../../../helpers/ffmpeg' import { logger } from '../../../helpers/logger' import { getSecureTorrentName } from '../../../helpers/utils' import { createTorrentAndSetInfoHash, downloadWebTorrentVideo } from '../../../helpers/webtorrent' @@ -80,7 +81,11 @@ async function processYoutubeDLImport (job: Job, videoImport: MVideoImportDefaul const options = { type: payload.type, videoImportId: videoImport.id } - const youtubeDL = new YoutubeDLWrapper(videoImport.targetUrl, ServerConfigManager.Instance.getEnabledResolutions('vod')) + const youtubeDL = new YoutubeDLWrapper( + videoImport.targetUrl, + ServerConfigManager.Instance.getEnabledResolutions('vod'), + CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION + ) return processFile( () => youtubeDL.downloadVideo(payload.fileExt, JOB_TTL['video-import']), diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 890d34e3b..4e5e97919 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts @@ -265,7 +265,7 @@ async function createLowerResolutionsJobs (options: { // Create transcoding jobs if there are enabled resolutions const resolutionsEnabled = await Hooks.wrapObject( - computeResolutionsToTranscode({ inputResolution: videoFileResolution, type: 'vod', includeInputResolution: false }), + computeResolutionsToTranscode({ input: videoFileResolution, type: 'vod', includeInput: false, strictLower: true }), 'filter:transcoding.auto.resolutions-to-transcode.result', options ) diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts index 3ac57fa44..1410889a2 100644 --- a/server/lib/live/live-manager.ts +++ b/server/lib/live/live-manager.ts @@ -456,10 +456,10 @@ class LiveManager { } private buildAllResolutionsToTranscode (originResolution: number) { - const includeInputResolution = CONFIG.LIVE.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION + const includeInput = CONFIG.LIVE.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION const resolutionsEnabled = CONFIG.LIVE.TRANSCODING.ENABLED - ? computeResolutionsToTranscode({ inputResolution: originResolution, type: 'live', includeInputResolution }) + ? computeResolutionsToTranscode({ input: originResolution, type: 'live', includeInput, strictLower: false }) : [] if (resolutionsEnabled.length === 0) { diff --git a/server/lib/transcoding/transcoding.ts b/server/lib/transcoding/transcoding.ts index 3681de994..070c7ebda 100644 --- a/server/lib/transcoding/transcoding.ts +++ b/server/lib/transcoding/transcoding.ts @@ -366,7 +366,7 @@ async function generateHlsPlaylistCommon (options: { function buildOriginalFileResolution (inputResolution: number) { if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) return toEven(inputResolution) - const resolutions = computeResolutionsToTranscode({ inputResolution, type: 'vod', includeInputResolution: false }) + const resolutions = computeResolutionsToTranscode({ input: inputResolution, type: 'vod', includeInput: false, strictLower: false }) if (resolutions.length === 0) return toEven(inputResolution) return Math.max(...resolutions) -- cgit v1.2.3