From a9f367ad9b4d77587126ef38b857f051ffc01bd3 Mon Sep 17 00:00:00 2001 From: HaveAGitGat Date: Fri, 21 Jun 2024 07:32:28 +0000 Subject: [PATCH] Apply auto-build changes --- .../1.0.0/index.js | 87 +++++++++++++++---- 1 file changed, 71 insertions(+), 16 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/ffmpegCommand/ffmpegCommandSetVideoEncoder/1.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/ffmpegCommand/ffmpegCommandSetVideoEncoder/1.0.0/index.js index 61427d065..d8d9b879c 100644 --- a/FlowPlugins/CommunityFlowPlugins/ffmpegCommand/ffmpegCommandSetVideoEncoder/1.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/ffmpegCommand/ffmpegCommandSetVideoEncoder/1.0.0/index.js @@ -70,6 +70,16 @@ var details = function () { return ({ }, tooltip: 'Specify codec of the output file', }, + { + label: 'Enable FFmpeg Preset', + name: 'ffmpegPresetEnabled', + type: 'boolean', + defaultValue: 'true', + inputUI: { + type: 'switch', + }, + tooltip: 'Specify whether to use an FFmpeg preset', + }, { label: 'FFmpeg Preset', name: 'ffmpegPreset', @@ -88,9 +98,34 @@ var details = function () { return ({ 'superfast', 'ultrafast', ], + displayConditions: { + logic: 'AND', + sets: [ + { + logic: 'AND', + inputs: [ + { + name: 'ffmpegPresetEnabled', + value: 'true', + condition: '===', + }, + ], + }, + ], + }, }, tooltip: 'Specify ffmpeg preset', }, + { + label: 'Enable FFmpeg CRF', + name: 'ffmpegQualityEnabled', + type: 'boolean', + defaultValue: 'true', + inputUI: { + type: 'switch', + }, + tooltip: 'Specify whether to set crf (or qp for GPU encoding)', + }, { label: 'FFmpeg Quality', name: 'ffmpegQuality', @@ -98,6 +133,21 @@ var details = function () { return ({ defaultValue: '25', inputUI: { type: 'text', + displayConditions: { + logic: 'AND', + sets: [ + { + logic: 'AND', + inputs: [ + { + name: 'ffmpegQualityEnabled', + value: 'true', + condition: '===', + }, + ], + }, + ], + }, }, tooltip: 'Specify ffmpeg quality', }, @@ -159,10 +209,10 @@ var details = function () { return ({ exports.details = details; // eslint-disable-next-line @typescript-eslint/no-unused-vars var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () { - var lib, hardwareDecoding, hardwareType, i, stream, targetCodec, ffmpegPreset, ffmpegQuality, forceEncoding, hardwarEncoding, encoderProperties; - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { + var lib, hardwareDecoding, hardwareType, i, stream, targetCodec, _a, ffmpegPresetEnabled, ffmpegQualityEnabled, ffmpegPreset, ffmpegQuality, forceEncoding, hardwarEncoding, encoderProperties; + var _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { case 0: lib = require('../../../../../methods/lib')(); // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign @@ -171,12 +221,13 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function hardwareType = String(args.inputs.hardwareType); args.variables.ffmpegCommand.hardwareDecoding = hardwareDecoding; i = 0; - _c.label = 1; + _d.label = 1; case 1: if (!(i < args.variables.ffmpegCommand.streams.length)) return [3 /*break*/, 4]; stream = args.variables.ffmpegCommand.streams[i]; if (!(stream.codec_type === 'video')) return [3 /*break*/, 3]; targetCodec = String(args.inputs.outputCodec); + _a = args.inputs, ffmpegPresetEnabled = _a.ffmpegPresetEnabled, ffmpegQualityEnabled = _a.ffmpegQualityEnabled; ffmpegPreset = String(args.inputs.ffmpegPreset); ffmpegQuality = String(args.inputs.ffmpegQuality); forceEncoding = args.inputs.forceEncoding === true; @@ -191,24 +242,28 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function args: args, })]; case 2: - encoderProperties = _c.sent(); + encoderProperties = _d.sent(); stream.outputArgs.push('-c:{outputIndex}', encoderProperties.encoder); - if (encoderProperties.isGpu) { - stream.outputArgs.push('-qp', ffmpegQuality); - } - else { - stream.outputArgs.push('-crf', ffmpegQuality); + if (ffmpegQualityEnabled) { + if (encoderProperties.isGpu) { + stream.outputArgs.push('-qp', ffmpegQuality); + } + else { + stream.outputArgs.push('-crf', ffmpegQuality); + } } - if (targetCodec !== 'av1' && ffmpegPreset) { - stream.outputArgs.push('-preset', ffmpegPreset); + if (ffmpegPresetEnabled) { + if (targetCodec !== 'av1' && ffmpegPreset) { + stream.outputArgs.push('-preset', ffmpegPreset); + } } if (hardwareDecoding) { - (_a = stream.inputArgs).push.apply(_a, encoderProperties.inputArgs); + (_b = stream.inputArgs).push.apply(_b, encoderProperties.inputArgs); } if (encoderProperties.outputArgs) { - (_b = stream.outputArgs).push.apply(_b, encoderProperties.outputArgs); + (_c = stream.outputArgs).push.apply(_c, encoderProperties.outputArgs); } - _c.label = 3; + _d.label = 3; case 3: i += 1; return [3 /*break*/, 1];