diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-05 15:05:20 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-09 09:18:07 +0200 |
commit | 5e2afe4290103bf0d54ae7b3e62781f2a00487c9 (patch) | |
tree | 84e084135c60d208fc9afcee63180d3200f763e6 /server/helpers/ffmpeg | |
parent | 64fd6158fd276f258bcfc4bb0c8fc2f64a220a11 (diff) | |
download | PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.tar.gz PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.tar.zst PeerTube-5e2afe4290103bf0d54ae7b3e62781f2a00487c9.zip |
Limit import depending on transcoding resolutions
Diffstat (limited to 'server/helpers/ffmpeg')
-rw-r--r-- | server/helpers/ffmpeg/ffprobe-utils.ts | 22 |
1 files changed, 14 insertions, 8 deletions
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) { | |||
91 | // --------------------------------------------------------------------------- | 91 | // --------------------------------------------------------------------------- |
92 | 92 | ||
93 | function computeResolutionsToTranscode (options: { | 93 | function computeResolutionsToTranscode (options: { |
94 | inputResolution: number | 94 | input: number |
95 | type: 'vod' | 'live' | 95 | type: 'vod' | 'live' |
96 | includeInputResolution: boolean | 96 | includeInput: boolean |
97 | strictLower: boolean | ||
97 | }) { | 98 | }) { |
98 | const { inputResolution, type, includeInputResolution } = options | 99 | const { input, type, includeInput, strictLower } = options |
99 | 100 | ||
100 | const configResolutions = type === 'vod' | 101 | const configResolutions = type === 'vod' |
101 | ? CONFIG.TRANSCODING.RESOLUTIONS | 102 | ? CONFIG.TRANSCODING.RESOLUTIONS |
@@ -117,13 +118,18 @@ function computeResolutionsToTranscode (options: { | |||
117 | ] | 118 | ] |
118 | 119 | ||
119 | for (const resolution of availableResolutions) { | 120 | for (const resolution of availableResolutions) { |
120 | if (configResolutions[resolution + 'p'] === true && inputResolution > resolution) { | 121 | // Resolution not enabled |
121 | resolutionsEnabled.add(resolution) | 122 | if (configResolutions[resolution + 'p'] !== true) continue |
122 | } | 123 | // Too big resolution for input file |
124 | if (input < resolution) continue | ||
125 | // We only want lower resolutions than input file | ||
126 | if (strictLower && input === resolution) continue | ||
127 | |||
128 | resolutionsEnabled.add(resolution) | ||
123 | } | 129 | } |
124 | 130 | ||
125 | if (includeInputResolution) { | 131 | if (includeInput) { |
126 | resolutionsEnabled.add(inputResolution) | 132 | resolutionsEnabled.add(input) |
127 | } | 133 | } |
128 | 134 | ||
129 | return Array.from(resolutionsEnabled) | 135 | return Array.from(resolutionsEnabled) |