1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Limit import depending on transcoding resolutions

This commit is contained in:
Chocobozzz 2022-08-05 15:05:20 +02:00
parent 64fd6158fd
commit 5e2afe4290
No known key found for this signature in database
GPG key ID: 583A612D890159BE
12 changed files with 144 additions and 43 deletions

View file

@ -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)