From 7ed2c1a46fd11caca16d5aec80d9f90d7a2d3429 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 4 May 2019 03:18:32 +0200 Subject: fixed formatting, added test case --- server/helpers/ffmpeg-utils.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 13bb2e894..af92d1ba9 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -173,7 +173,7 @@ function transcode (options: TranscodeOptions) { }) } -async function canDoQuickTranscode (path: string) { +async function canDoQuickTranscode (path: string): Promise { // NOTE: This could be optimized by running ffprobe only once (but it runs fast anyway) const videoStream = await getVideoStreamFromFile(path) const parsedAudio = await audio.get(path) @@ -182,22 +182,27 @@ async function canDoQuickTranscode (path: string) { const resolution = await getVideoFileResolution(path) // check video params - if (videoStream[ 'codec_name' ] !== 'h264') + if (videoStream[ 'codec_name' ] !== 'h264') { return false - if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) + } + if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) { return false - if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) + } + if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) { return false + } // check audio params (if audio stream exists) if (parsedAudio.audioStream) { - if (parsedAudio.audioStream[ 'codec_name' ] !== 'aac') + if (parsedAudio.audioStream[ 'codec_name' ] !== 'aac') { return false + } const maxAudioBitrate = audio.bitrate[ 'aac' ](parsedAudio.audioStream[ 'bit_rate' ]) - if (maxAudioBitrate != -1 && parsedAudio.audioStream[ 'bit_rate' ] > maxAudioBitrate) + if (maxAudioBitrate !== -1 && parsedAudio.audioStream[ 'bit_rate' ] > maxAudioBitrate) { return false + } } - + return true } -- cgit v1.2.3