aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/ffmpeg/ffprobe-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-08-05 10:36:19 +0200
committerChocobozzz <me@florianbigard.com>2022-08-09 09:18:07 +0200
commit84cae54e7a2595bea0c3ea106a4d111fd11a4ec6 (patch)
tree03fe73edf049ce60df6bbc34dcfb2031c07ea59c /server/helpers/ffmpeg/ffprobe-utils.ts
parent7e0f50d6e0c7dc583d40e196c283eb20dc386ae6 (diff)
downloadPeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.tar.gz
PeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.tar.zst
PeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.zip
Add option to not transcode original resolution
Diffstat (limited to 'server/helpers/ffmpeg/ffprobe-utils.ts')
-rw-r--r--server/helpers/ffmpeg/ffprobe-utils.ts26
1 files changed, 18 insertions, 8 deletions
diff --git a/server/helpers/ffmpeg/ffprobe-utils.ts b/server/helpers/ffmpeg/ffprobe-utils.ts
index 9529162eb..7bcd27665 100644
--- a/server/helpers/ffmpeg/ffprobe-utils.ts
+++ b/server/helpers/ffmpeg/ffprobe-utils.ts
@@ -90,15 +90,21 @@ async function getAudioStreamCodec (path: string, existingProbe?: FfprobeData) {
90// Resolutions 90// Resolutions
91// --------------------------------------------------------------------------- 91// ---------------------------------------------------------------------------
92 92
93function computeLowerResolutionsToTranscode (videoFileResolution: number, type: 'vod' | 'live') { 93function computeResolutionsToTranscode (options: {
94 inputResolution: number
95 type: 'vod' | 'live'
96 includeInputResolution: boolean
97}) {
98 const { inputResolution, type, includeInputResolution } = options
99
94 const configResolutions = type === 'vod' 100 const configResolutions = type === 'vod'
95 ? CONFIG.TRANSCODING.RESOLUTIONS 101 ? CONFIG.TRANSCODING.RESOLUTIONS
96 : CONFIG.LIVE.TRANSCODING.RESOLUTIONS 102 : CONFIG.LIVE.TRANSCODING.RESOLUTIONS
97 103
98 const resolutionsEnabled: number[] = [] 104 const resolutionsEnabled = new Set<number>()
99 105
100 // Put in the order we want to proceed jobs 106 // Put in the order we want to proceed jobs
101 const resolutions: VideoResolution[] = [ 107 const availableResolutions: VideoResolution[] = [
102 VideoResolution.H_NOVIDEO, 108 VideoResolution.H_NOVIDEO,
103 VideoResolution.H_480P, 109 VideoResolution.H_480P,
104 VideoResolution.H_360P, 110 VideoResolution.H_360P,
@@ -110,13 +116,17 @@ function computeLowerResolutionsToTranscode (videoFileResolution: number, type:
110 VideoResolution.H_4K 116 VideoResolution.H_4K
111 ] 117 ]
112 118
113 for (const resolution of resolutions) { 119 for (const resolution of availableResolutions) {
114 if (configResolutions[resolution + 'p'] === true && videoFileResolution > resolution) { 120 if (configResolutions[resolution + 'p'] === true && inputResolution > resolution) {
115 resolutionsEnabled.push(resolution) 121 resolutionsEnabled.add(resolution)
116 } 122 }
117 } 123 }
118 124
119 return resolutionsEnabled 125 if (includeInputResolution) {
126 resolutionsEnabled.add(inputResolution)
127 }
128
129 return Array.from(resolutionsEnabled)
120} 130}
121 131
122// --------------------------------------------------------------------------- 132// ---------------------------------------------------------------------------
@@ -224,7 +234,7 @@ export {
224 computeFPS, 234 computeFPS,
225 getClosestFramerateStandard, 235 getClosestFramerateStandard,
226 236
227 computeLowerResolutionsToTranscode, 237 computeResolutionsToTranscode,
228 238
229 canDoQuickTranscode, 239 canDoQuickTranscode,
230 canDoQuickVideoTranscode, 240 canDoQuickVideoTranscode,