Rename plugin, throw error if no video streams found

make-only-subtitle-default
HaveAGitGat 2 years ago
parent 491e40b885
commit 6af54253ba

@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.plugin = exports.details = void 0; exports.plugin = exports.details = void 0;
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ /* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
var details = function () { return ({ var details = function () { return ({
name: 'Check Multiple Video Streams', name: 'Check Video Streams Count',
description: 'This plugin checks if an input file has more than one video stream.', description: 'This plugin checks if the number of video streams is 1 or more.',
style: { style: {
borderColor: 'orange', borderColor: 'orange',
}, },
@ -32,14 +32,20 @@ var plugin = function (args) {
var lib = require('../../../../../methods/lib')(); var lib = require('../../../../../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details); args.inputs = lib.loadDefaultValues(args.inputs, details);
var outputNumber = 2; // Default to 'Special case' (> 1 video tracks)
var ffProbeData = args.inputFileObj.ffProbeData; var ffProbeData = args.inputFileObj.ffProbeData;
if (!ffProbeData || !ffProbeData.streams) { if (!ffProbeData || !ffProbeData.streams) {
throw new Error('ffProbeData or ffProbeData.streams is not available.'); throw new Error('ffProbeData or ffProbeData.streams is not available.');
} }
var videoStreams = ffProbeData.streams.filter(function (stream) { return stream.codec_type === 'video'; }).length; var videoStreams = ffProbeData.streams.filter(function (stream) { return stream.codec_type === 'video'; }).length;
if (videoStreams === 1) { var outputNumber = 1; // Default to one video stream
outputNumber = 1; // 'Success' (has exactly 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 = 3; // More than one video stream
} }
return { return {
outputFileObj: args.inputFileObj, outputFileObj: args.inputFileObj,

@ -6,8 +6,8 @@ import {
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ /* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({ const details = (): IpluginDetails => ({
name: 'Check Multiple Video Streams', name: 'Check Video Streams Count',
description: 'This plugin checks if an input file has more than one video stream.', description: 'This plugin checks if the number of video streams is 1 or more.',
style: { style: {
borderColor: 'orange', borderColor: 'orange',
}, },
@ -36,8 +36,6 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details); args.inputs = lib.loadDefaultValues(args.inputs, details);
let outputNumber = 2; // Default to 'Special case' (> 1 video tracks)
const { ffProbeData } = args.inputFileObj; const { ffProbeData } = args.inputFileObj;
if (!ffProbeData || !ffProbeData.streams) { if (!ffProbeData || !ffProbeData.streams) {
@ -46,8 +44,14 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
const videoStreams = ffProbeData.streams.filter((stream) => stream.codec_type === 'video').length; const videoStreams = ffProbeData.streams.filter((stream) => stream.codec_type === 'video').length;
if (videoStreams === 1) { let outputNumber = 1; // Default to one video stream
outputNumber = 1; // 'Success' (has exactly 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
} }
return { return {
Loading…
Cancel
Save