diff options
Diffstat (limited to 'server/helpers/ffprobe-utils.ts')
-rw-r--r-- | server/helpers/ffprobe-utils.ts | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts index 6159d3963..5545ddbbf 100644 --- a/server/helpers/ffprobe-utils.ts +++ b/server/helpers/ffprobe-utils.ts | |||
@@ -198,9 +198,12 @@ function computeResolutionsToTranscode (videoFileResolution: number, type: 'vod' | |||
198 | async function canDoQuickTranscode (path: string): Promise<boolean> { | 198 | async function canDoQuickTranscode (path: string): Promise<boolean> { |
199 | const probe = await ffprobePromise(path) | 199 | const probe = await ffprobePromise(path) |
200 | 200 | ||
201 | // NOTE: This could be optimized by running ffprobe only once (but it runs fast anyway) | 201 | return await canDoQuickVideoTranscode(path, probe) && |
202 | await canDoQuickAudioTranscode(path, probe) | ||
203 | } | ||
204 | |||
205 | async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> { | ||
202 | const videoStream = await getVideoStreamFromFile(path, probe) | 206 | const videoStream = await getVideoStreamFromFile(path, probe) |
203 | const parsedAudio = await getAudioStream(path, probe) | ||
204 | const fps = await getVideoFileFPS(path, probe) | 207 | const fps = await getVideoFileFPS(path, probe) |
205 | const bitRate = await getVideoFileBitrate(path, probe) | 208 | const bitRate = await getVideoFileBitrate(path, probe) |
206 | const resolution = await getVideoFileResolution(path, probe) | 209 | const resolution = await getVideoFileResolution(path, probe) |
@@ -212,6 +215,12 @@ async function canDoQuickTranscode (path: string): Promise<boolean> { | |||
212 | if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) return false | 215 | if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) return false |
213 | if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) return false | 216 | if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) return false |
214 | 217 | ||
218 | return true | ||
219 | } | ||
220 | |||
221 | async function canDoQuickAudioTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> { | ||
222 | const parsedAudio = await getAudioStream(path, probe) | ||
223 | |||
215 | // check audio params (if audio stream exists) | 224 | // check audio params (if audio stream exists) |
216 | if (parsedAudio.audioStream) { | 225 | if (parsedAudio.audioStream) { |
217 | if (parsedAudio.audioStream['codec_name'] !== 'aac') return false | 226 | if (parsedAudio.audioStream['codec_name'] !== 'aac') return false |
@@ -239,11 +248,15 @@ export { | |||
239 | getVideoFileResolution, | 248 | getVideoFileResolution, |
240 | getMetadataFromFile, | 249 | getMetadataFromFile, |
241 | getMaxAudioBitrate, | 250 | getMaxAudioBitrate, |
251 | getVideoStreamFromFile, | ||
242 | getDurationFromVideoFile, | 252 | getDurationFromVideoFile, |
243 | getAudioStream, | 253 | getAudioStream, |
244 | getVideoFileFPS, | 254 | getVideoFileFPS, |
255 | ffprobePromise, | ||
245 | getClosestFramerateStandard, | 256 | getClosestFramerateStandard, |
246 | computeResolutionsToTranscode, | 257 | computeResolutionsToTranscode, |
247 | getVideoFileBitrate, | 258 | getVideoFileBitrate, |
248 | canDoQuickTranscode | 259 | canDoQuickTranscode, |
260 | canDoQuickVideoTranscode, | ||
261 | canDoQuickAudioTranscode | ||
249 | } | 262 | } |