mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 07:29:04 -07:00
Merge pull request #674 from HaveAGitGat/ffmpeg_c
Add toggles for preset and quality
This commit is contained in:
commit
fa784a12ce
2 changed files with 132 additions and 22 deletions
|
|
@ -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);
|
||||
if (ffmpegQualityEnabled) {
|
||||
if (encoderProperties.isGpu) {
|
||||
stream.outputArgs.push('-qp', ffmpegQuality);
|
||||
}
|
||||
else {
|
||||
stream.outputArgs.push('-crf', 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];
|
||||
|
|
|
|||
|
|
@ -38,6 +38,16 @@ const details = (): IpluginDetails => ({
|
|||
},
|
||||
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',
|
||||
|
|
@ -56,9 +66,34 @@ const details = (): IpluginDetails => ({
|
|||
'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',
|
||||
|
|
@ -66,6 +101,21 @@ const details = (): IpluginDetails => ({
|
|||
defaultValue: '25',
|
||||
inputUI: {
|
||||
type: 'text',
|
||||
displayConditions: {
|
||||
logic: 'AND',
|
||||
sets: [
|
||||
{
|
||||
logic: 'AND',
|
||||
inputs: [
|
||||
{
|
||||
name: 'ffmpegQualityEnabled',
|
||||
value: 'true',
|
||||
condition: '===',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
tooltip: 'Specify ffmpeg quality',
|
||||
},
|
||||
|
|
@ -140,6 +190,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
|
||||
if (stream.codec_type === 'video') {
|
||||
const targetCodec = String(args.inputs.outputCodec);
|
||||
const { ffmpegPresetEnabled, ffmpegQualityEnabled } = args.inputs;
|
||||
const ffmpegPreset = String(args.inputs.ffmpegPreset);
|
||||
const ffmpegQuality = String(args.inputs.ffmpegQuality);
|
||||
const forceEncoding = args.inputs.forceEncoding === true;
|
||||
|
|
@ -161,14 +212,18 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue