From 85c8d47058cadcc5eb7d23dcb29209d5ea9586a5 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Wed, 19 Feb 2020 12:56:37 +0800 Subject: [PATCH] fix division by zero --- src/ffmpeg.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ffmpeg.js b/src/ffmpeg.js index 3e182b6f..39bff1e7 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -433,7 +433,9 @@ const defaultProcessedCodecTypes = [ function getStreamFps(stream) { const match = typeof stream.avg_frame_rate === 'string' && stream.avg_frame_rate.match(/^([0-9]+)\/([0-9]+)$/); if (stream.codec_type === 'video' && match) { - return parseInt(match[1], 10) / parseInt(match[2], 10); + const num = parseInt(match[1], 10); + const den = parseInt(match[2], 10); + if (den > 0) return num / den; } return undefined; }