diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-14 15:28:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-14 15:28:30 +0200 |
commit | 06215f15e0a9fea2ef95b8b49cb2b5868fb64017 (patch) | |
tree | 6f7ff9f82ea851ea87fd3fc4b61843c7a38aec43 /server/helpers/ffmpeg-utils.ts | |
parent | 59c76ffa8f503e962d517c78f033f1beccb1de1a (diff) | |
download | PeerTube-06215f15e0a9fea2ef95b8b49cb2b5868fb64017.tar.gz PeerTube-06215f15e0a9fea2ef95b8b49cb2b5868fb64017.tar.zst PeerTube-06215f15e0a9fea2ef95b8b49cb2b5868fb64017.zip |
Cleanup utils helper
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index ced56b82d..f8299c36f 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -7,6 +7,28 @@ import { processImage } from './image-utils' | |||
7 | import { logger } from './logger' | 7 | import { logger } from './logger' |
8 | import { checkFFmpegEncoders } from '../initializers/checker' | 8 | import { checkFFmpegEncoders } from '../initializers/checker' |
9 | 9 | ||
10 | function computeResolutionsToTranscode (videoFileHeight: number) { | ||
11 | const resolutionsEnabled: number[] = [] | ||
12 | const configResolutions = CONFIG.TRANSCODING.RESOLUTIONS | ||
13 | |||
14 | // Put in the order we want to proceed jobs | ||
15 | const resolutions = [ | ||
16 | VideoResolution.H_480P, | ||
17 | VideoResolution.H_360P, | ||
18 | VideoResolution.H_720P, | ||
19 | VideoResolution.H_240P, | ||
20 | VideoResolution.H_1080P | ||
21 | ] | ||
22 | |||
23 | for (const resolution of resolutions) { | ||
24 | if (configResolutions[ resolution + 'p' ] === true && videoFileHeight > resolution) { | ||
25 | resolutionsEnabled.push(resolution) | ||
26 | } | ||
27 | } | ||
28 | |||
29 | return resolutionsEnabled | ||
30 | } | ||
31 | |||
10 | async function getVideoFileResolution (path: string) { | 32 | async function getVideoFileResolution (path: string) { |
11 | const videoStream = await getVideoFileStream(path) | 33 | const videoStream = await getVideoFileStream(path) |
12 | 34 | ||
@@ -134,6 +156,7 @@ export { | |||
134 | generateImageFromVideoFile, | 156 | generateImageFromVideoFile, |
135 | transcode, | 157 | transcode, |
136 | getVideoFileFPS, | 158 | getVideoFileFPS, |
159 | computeResolutionsToTranscode, | ||
137 | audio | 160 | audio |
138 | } | 161 | } |
139 | 162 | ||