aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-08-05 15:05:20 +0200
committerChocobozzz <me@florianbigard.com>2022-08-09 09:18:07 +0200
commit5e2afe4290103bf0d54ae7b3e62781f2a00487c9 (patch)
tree84e084135c60d208fc9afcee63180d3200f763e6 /server/lib
parent64fd6158fd276f258bcfc4bb0c8fc2f64a220a11 (diff)
downloadPeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.tar.gz
PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.tar.zst
PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.zip
Limit import depending on transcoding resolutions
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/job-queue/handlers/video-import.ts9
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts2
-rw-r--r--server/lib/live/live-manager.ts4
-rw-r--r--server/lib/transcoding/transcoding.ts2
4 files changed, 11 insertions, 6 deletions
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'
2import { move, remove, stat } from 'fs-extra' 2import { move, remove, stat } from 'fs-extra'
3import { retryTransactionWrapper } from '@server/helpers/database-utils' 3import { retryTransactionWrapper } from '@server/helpers/database-utils'
4import { YoutubeDLWrapper } from '@server/helpers/youtube-dl' 4import { YoutubeDLWrapper } from '@server/helpers/youtube-dl'
5import { CONFIG } from '@server/initializers/config'
5import { isPostImportVideoAccepted } from '@server/lib/moderation' 6import { isPostImportVideoAccepted } from '@server/lib/moderation'
6import { generateWebTorrentVideoFilename } from '@server/lib/paths' 7import { generateWebTorrentVideoFilename } from '@server/lib/paths'
7import { Hooks } from '@server/lib/plugins/hooks' 8import { Hooks } from '@server/lib/plugins/hooks'
@@ -25,7 +26,7 @@ import {
25 VideoResolution, 26 VideoResolution,
26 VideoState 27 VideoState
27} from '@shared/models' 28} from '@shared/models'
28import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, getVideoStreamDimensionsInfo } from '../../../helpers/ffmpeg' 29import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamDuration, getVideoStreamFPS } from '../../../helpers/ffmpeg'
29import { logger } from '../../../helpers/logger' 30import { logger } from '../../../helpers/logger'
30import { getSecureTorrentName } from '../../../helpers/utils' 31import { getSecureTorrentName } from '../../../helpers/utils'
31import { createTorrentAndSetInfoHash, downloadWebTorrentVideo } from '../../../helpers/webtorrent' 32import { createTorrentAndSetInfoHash, downloadWebTorrentVideo } from '../../../helpers/webtorrent'
@@ -80,7 +81,11 @@ async function processYoutubeDLImport (job: Job, videoImport: MVideoImportDefaul
80 81
81 const options = { type: payload.type, videoImportId: videoImport.id } 82 const options = { type: payload.type, videoImportId: videoImport.id }
82 83
83 const youtubeDL = new YoutubeDLWrapper(videoImport.targetUrl, ServerConfigManager.Instance.getEnabledResolutions('vod')) 84 const youtubeDL = new YoutubeDLWrapper(
85 videoImport.targetUrl,
86 ServerConfigManager.Instance.getEnabledResolutions('vod'),
87 CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION
88 )
84 89
85 return processFile( 90 return processFile(
86 () => youtubeDL.downloadVideo(payload.fileExt, JOB_TTL['video-import']), 91 () => 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: {
265 265
266 // Create transcoding jobs if there are enabled resolutions 266 // Create transcoding jobs if there are enabled resolutions
267 const resolutionsEnabled = await Hooks.wrapObject( 267 const resolutionsEnabled = await Hooks.wrapObject(
268 computeResolutionsToTranscode({ inputResolution: videoFileResolution, type: 'vod', includeInputResolution: false }), 268 computeResolutionsToTranscode({ input: videoFileResolution, type: 'vod', includeInput: false, strictLower: true }),
269 'filter:transcoding.auto.resolutions-to-transcode.result', 269 'filter:transcoding.auto.resolutions-to-transcode.result',
270 options 270 options
271 ) 271 )
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 {
456 } 456 }
457 457
458 private buildAllResolutionsToTranscode (originResolution: number) { 458 private buildAllResolutionsToTranscode (originResolution: number) {
459 const includeInputResolution = CONFIG.LIVE.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION 459 const includeInput = CONFIG.LIVE.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION
460 460
461 const resolutionsEnabled = CONFIG.LIVE.TRANSCODING.ENABLED 461 const resolutionsEnabled = CONFIG.LIVE.TRANSCODING.ENABLED
462 ? computeResolutionsToTranscode({ inputResolution: originResolution, type: 'live', includeInputResolution }) 462 ? computeResolutionsToTranscode({ input: originResolution, type: 'live', includeInput, strictLower: false })
463 : [] 463 : []
464 464
465 if (resolutionsEnabled.length === 0) { 465 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: {
366function buildOriginalFileResolution (inputResolution: number) { 366function buildOriginalFileResolution (inputResolution: number) {
367 if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) return toEven(inputResolution) 367 if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) return toEven(inputResolution)
368 368
369 const resolutions = computeResolutionsToTranscode({ inputResolution, type: 'vod', includeInputResolution: false }) 369 const resolutions = computeResolutionsToTranscode({ input: inputResolution, type: 'vod', includeInput: false, strictLower: false })
370 if (resolutions.length === 0) return toEven(inputResolution) 370 if (resolutions.length === 0) return toEven(inputResolution)
371 371
372 return Math.max(...resolutions) 372 return Math.max(...resolutions)