You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.9 KiB

/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
import {
IpluginDetails,
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
/* eslint-disable no-param-reassign */
const details = () :IpluginDetails => ({
name: 'Set Video Encoder',
description: 'Set the video encoder for all streams',
style: {
borderColor: '#6efefc',
},
tags: 'video',
isStartPlugin: false,
sidebarPosition: -1,
icon: '',
inputs: [
{
name: 'targetCodec',
type: 'string',
defaultValue: 'hevc',
inputUI: {
type: 'dropdown',
options: [
'hevc',
// 'vp9',
'h264',
// 'vp8',
],
},
tooltip: 'Specify the codec to use',
},
{
name: 'forceEncoding',
type: 'boolean',
defaultValue: 'false',
inputUI: {
type: 'dropdown',
options: [
'false',
'true',
],
},
tooltip: 'Specify whether to force encoding if stream already has the target codec',
},
],
outputs: [
{
number: 1,
tooltip: 'Continue to next plugin',
},
],
});
// 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);
// @ts-expect-error type
args.variables.ffmpegCommand.streams.forEach((stream) => {
if (stream.codec_type === 'video') {
// @ts-expect-error type
stream.targetCodec = args.inputs.targetCodec;
stream.forceEncoding = args.inputs.forceEncoding;
}
});
return {
outputFileObj: args.inputFileObj,
outputNumber: 1,
variables: args.variables,
};
};
export {
details,
plugin,
};