From 491e40b885938619f16251c3f51ff7d46fcf626d Mon Sep 17 00:00:00 2001 From: Stickie Date: Thu, 5 Oct 2023 13:16:44 +0200 Subject: [PATCH] Added `CheckVideoChannelsAmount` Flow plugin. --- .../CheckVideoChannelsAmount/1.0.0/index.js | 50 +++++++++++++++ .../CheckVideoChannelsAmount/1.0.0/index.ts | 63 +++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 FlowPlugins/CommunityFlowPlugins/video/CheckVideoChannelsAmount/1.0.0/index.js create mode 100644 FlowPluginsTs/CommunityFlowPlugins/video/CheckVideoChannelsAmount/1.0.0/index.ts diff --git a/FlowPlugins/CommunityFlowPlugins/video/CheckVideoChannelsAmount/1.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/video/CheckVideoChannelsAmount/1.0.0/index.js new file mode 100644 index 0000000..4c2cafb --- /dev/null +++ b/FlowPlugins/CommunityFlowPlugins/video/CheckVideoChannelsAmount/1.0.0/index.js @@ -0,0 +1,50 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.plugin = exports.details = void 0; +/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ +var details = function () { return ({ + name: 'Check Multiple Video Streams', + description: 'This plugin checks if an input file has more than one video stream.', + style: { + borderColor: 'orange', + }, + tags: 'video', + isStartPlugin: false, + pType: '', + requiresVersion: '2.11.01', + sidebarPosition: -1, + icon: 'faQuestion', + inputs: [], + outputs: [ + { + number: 1, + tooltip: 'File has one video stream', + }, + { + number: 2, + tooltip: 'File has more than one video stream', + }, + ], +}); }; +exports.details = details; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +var plugin = function (args) { + var lib = require('../../../../../methods/lib')(); + // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign + args.inputs = lib.loadDefaultValues(args.inputs, details); + var outputNumber = 2; // Default to 'Special case' (> 1 video tracks) + var ffProbeData = args.inputFileObj.ffProbeData; + if (!ffProbeData || !ffProbeData.streams) { + throw new Error('ffProbeData or ffProbeData.streams is not available.'); + } + var videoStreams = ffProbeData.streams.filter(function (stream) { return stream.codec_type === 'video'; }).length; + if (videoStreams === 1) { + outputNumber = 1; // 'Success' (has exactly one video stream) + } + return { + outputFileObj: args.inputFileObj, + outputNumber: outputNumber, + variables: args.variables, + }; +}; +exports.plugin = plugin; diff --git a/FlowPluginsTs/CommunityFlowPlugins/video/CheckVideoChannelsAmount/1.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/video/CheckVideoChannelsAmount/1.0.0/index.ts new file mode 100644 index 0000000..940aa2a --- /dev/null +++ b/FlowPluginsTs/CommunityFlowPlugins/video/CheckVideoChannelsAmount/1.0.0/index.ts @@ -0,0 +1,63 @@ +import { + IpluginDetails, + IpluginInputArgs, + IpluginOutputArgs, +} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces'; + +/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ +const details = (): IpluginDetails => ({ + name: 'Check Multiple Video Streams', + description: 'This plugin checks if an input file has more than one video stream.', + style: { + borderColor: 'orange', + }, + tags: 'video', + isStartPlugin: false, + pType: '', + requiresVersion: '2.11.01', + sidebarPosition: -1, + icon: 'faQuestion', + inputs: [], + outputs: [ + { + number: 1, + tooltip: 'File has one video stream', + }, + { + number: 2, + tooltip: 'File has more than one video stream', + }, + ], +}); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const plugin = (args: IpluginInputArgs): IpluginOutputArgs => { + const lib = require('../../../../../methods/lib')(); + // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign + args.inputs = lib.loadDefaultValues(args.inputs, details); + + let outputNumber = 2; // Default to 'Special case' (> 1 video tracks) + + const { ffProbeData } = args.inputFileObj; + + if (!ffProbeData || !ffProbeData.streams) { + throw new Error('ffProbeData or ffProbeData.streams is not available.'); + } + + const videoStreams = ffProbeData.streams.filter((stream) => stream.codec_type === 'video').length; + + if (videoStreams === 1) { + outputNumber = 1; // 'Success' (has exactly one video stream) + } + + return { + outputFileObj: args.inputFileObj, + outputNumber, + variables: args.variables, + }; +}; + +export { + details, + plugin, +};