aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/ffmpeg-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r--server/helpers/ffmpeg-utils.ts22
1 files changed, 7 insertions, 15 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index af92d1ba9..2fdf34cb7 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -139,6 +139,7 @@ function transcode (options: TranscodeOptions) {
139 if (options.hlsPlaylist) { 139 if (options.hlsPlaylist) {
140 throw(Error("Quick transcode and HLS can't be used at the same time")) 140 throw(Error("Quick transcode and HLS can't be used at the same time"))
141 } 141 }
142
142 command 143 command
143 .format('mp4') 144 .format('mp4')
144 .addOption('-c:v copy') 145 .addOption('-c:v copy')
@@ -182,25 +183,16 @@ async function canDoQuickTranscode (path: string): Promise<boolean> {
182 const resolution = await getVideoFileResolution(path) 183 const resolution = await getVideoFileResolution(path)
183 184
184 // check video params 185 // check video params
185 if (videoStream[ 'codec_name' ] !== 'h264') { 186 if (videoStream[ 'codec_name' ] !== 'h264') return false
186 return false 187 if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) return false
187 } 188 if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) return false
188 if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) {
189 return false
190 }
191 if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) {
192 return false
193 }
194 189
195 // check audio params (if audio stream exists) 190 // check audio params (if audio stream exists)
196 if (parsedAudio.audioStream) { 191 if (parsedAudio.audioStream) {
197 if (parsedAudio.audioStream[ 'codec_name' ] !== 'aac') { 192 if (parsedAudio.audioStream[ 'codec_name' ] !== 'aac') return false
198 return false 193
199 }
200 const maxAudioBitrate = audio.bitrate[ 'aac' ](parsedAudio.audioStream[ 'bit_rate' ]) 194 const maxAudioBitrate = audio.bitrate[ 'aac' ](parsedAudio.audioStream[ 'bit_rate' ])
201 if (maxAudioBitrate !== -1 && parsedAudio.audioStream[ 'bit_rate' ] > maxAudioBitrate) { 195 if (maxAudioBitrate !== -1 && parsedAudio.audioStream[ 'bit_rate' ] > maxAudioBitrate) return false
202 return false
203 }
204 } 196 }
205 197
206 return true 198 return true