From 98f8172dd025d7d16d2c5bf7ac1eb152890d44b6 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Thu, 7 Sep 2023 04:58:15 +0100 Subject: [PATCH] Throw error if video bitrate not found --- .../video/checkVideoBitrate/1.0.0/index.js | 7 +++++++ .../video/checkVideoBitrate/1.0.0/index.ts | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/FlowPlugins/CommunityFlowPlugins/video/checkVideoBitrate/1.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/video/checkVideoBitrate/1.0.0/index.js index e9dd45d..4ff8f13 100644 --- a/FlowPlugins/CommunityFlowPlugins/video/checkVideoBitrate/1.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/video/checkVideoBitrate/1.0.0/index.js @@ -77,15 +77,22 @@ var plugin = function (args) { greaterThanBits *= 1000000; lessThanBits *= 1000000; } + var hasVideoBitrate = false; if ((_b = (_a = args.inputFileObj) === null || _a === void 0 ? void 0 : _a.mediaInfo) === null || _b === void 0 ? void 0 : _b.track) { args.inputFileObj.mediaInfo.track.forEach(function (stream) { if (stream['@type'] === 'video') { + if (stream.BitRate) { + hasVideoBitrate = true; + } if (stream.BitRate >= greaterThanBits && stream.BitRate <= lessThanBits) { isWithinRange = true; } } }); } + if (!hasVideoBitrate) { + throw new Error('Video bitrate not found'); + } return { outputFileObj: args.inputFileObj, outputNumber: isWithinRange ? 1 : 2, diff --git a/FlowPluginsTs/CommunityFlowPlugins/video/checkVideoBitrate/1.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/video/checkVideoBitrate/1.0.0/index.ts index 082916b..f689638 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/video/checkVideoBitrate/1.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/video/checkVideoBitrate/1.0.0/index.ts @@ -82,9 +82,14 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => { lessThanBits *= 1000000; } + let hasVideoBitrate = false; + if (args.inputFileObj?.mediaInfo?.track) { args.inputFileObj.mediaInfo.track.forEach((stream) => { if (stream['@type'] === 'video') { + if (stream.BitRate) { + hasVideoBitrate = true; + } if (stream.BitRate >= greaterThanBits && stream.BitRate <= lessThanBits) { isWithinRange = true; } @@ -92,6 +97,10 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => { }); } + if (!hasVideoBitrate) { + throw new Error('Video bitrate not found'); + } + return { outputFileObj: args.inputFileObj, outputNumber: isWithinRange ? 1 : 2,