-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #496 from StickieBE/master
Added `CheckVideoChannelsAmount` Flow plugin.
- Loading branch information
Showing
2 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
FlowPlugins/CommunityFlowPlugins/video/checkVideoStreamsCount/1.0.0/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"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 Video Streams Count', | ||
description: 'This plugin checks if the number of video streams is 1 or more.', | ||
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 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; | ||
var outputNumber = 1; // Default to one video stream | ||
if (videoStreams === 0) { | ||
throw new Error('No video streams found in file.'); | ||
} | ||
else if (videoStreams === 1) { | ||
outputNumber = 1; // One video stream | ||
} | ||
else if (videoStreams > 1) { | ||
outputNumber = 2; // More than one video stream | ||
} | ||
args.jobLog("Number of video streams: ".concat(videoStreams)); | ||
return { | ||
outputFileObj: args.inputFileObj, | ||
outputNumber: outputNumber, | ||
variables: args.variables, | ||
}; | ||
}; | ||
exports.plugin = plugin; |
69 changes: 69 additions & 0 deletions
69
FlowPluginsTs/CommunityFlowPlugins/video/checkVideoStreamsCount/1.0.0/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
IpluginDetails, | ||
IpluginInputArgs, | ||
IpluginOutputArgs, | ||
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces'; | ||
|
||
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ | ||
const details = (): IpluginDetails => ({ | ||
name: 'Check Video Streams Count', | ||
description: 'This plugin checks if the number of video streams is 1 or more.', | ||
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); | ||
|
||
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; | ||
|
||
let outputNumber = 1; // Default to one video stream | ||
|
||
if (videoStreams === 0) { | ||
throw new Error('No video streams found in file.'); | ||
} else if (videoStreams === 1) { | ||
outputNumber = 1; // One video stream | ||
} else if (videoStreams > 1) { | ||
outputNumber = 2; // More than one video stream | ||
} | ||
|
||
args.jobLog(`Number of video streams: ${videoStreams}`); | ||
|
||
return { | ||
outputFileObj: args.inputFileObj, | ||
outputNumber, | ||
variables: args.variables, | ||
}; | ||
}; | ||
|
||
export { | ||
details, | ||
plugin, | ||
}; |