mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-15 18:25:54 -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',
|
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',
|
label: 'FFmpeg Preset',
|
||||||
name: 'ffmpegPreset',
|
name: 'ffmpegPreset',
|
||||||
|
|
@ -88,9 +98,34 @@ var details = function () { return ({
|
||||||
'superfast',
|
'superfast',
|
||||||
'ultrafast',
|
'ultrafast',
|
||||||
],
|
],
|
||||||
|
displayConditions: {
|
||||||
|
logic: 'AND',
|
||||||
|
sets: [
|
||||||
|
{
|
||||||
|
logic: 'AND',
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
name: 'ffmpegPresetEnabled',
|
||||||
|
value: 'true',
|
||||||
|
condition: '===',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tooltip: 'Specify ffmpeg preset',
|
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',
|
label: 'FFmpeg Quality',
|
||||||
name: 'ffmpegQuality',
|
name: 'ffmpegQuality',
|
||||||
|
|
@ -98,6 +133,21 @@ var details = function () { return ({
|
||||||
defaultValue: '25',
|
defaultValue: '25',
|
||||||
inputUI: {
|
inputUI: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
displayConditions: {
|
||||||
|
logic: 'AND',
|
||||||
|
sets: [
|
||||||
|
{
|
||||||
|
logic: 'AND',
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
name: 'ffmpegQualityEnabled',
|
||||||
|
value: 'true',
|
||||||
|
condition: '===',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tooltip: 'Specify ffmpeg quality',
|
tooltip: 'Specify ffmpeg quality',
|
||||||
},
|
},
|
||||||
|
|
@ -159,10 +209,10 @@ var details = function () { return ({
|
||||||
exports.details = details;
|
exports.details = details;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
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 lib, hardwareDecoding, hardwareType, i, stream, targetCodec, _a, ffmpegPresetEnabled, ffmpegQualityEnabled, ffmpegPreset, ffmpegQuality, forceEncoding, hardwarEncoding, encoderProperties;
|
||||||
var _a, _b;
|
var _b, _c;
|
||||||
return __generator(this, function (_c) {
|
return __generator(this, function (_d) {
|
||||||
switch (_c.label) {
|
switch (_d.label) {
|
||||||
case 0:
|
case 0:
|
||||||
lib = require('../../../../../methods/lib')();
|
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
|
||||||
|
|
@ -171,12 +221,13 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
hardwareType = String(args.inputs.hardwareType);
|
hardwareType = String(args.inputs.hardwareType);
|
||||||
args.variables.ffmpegCommand.hardwareDecoding = hardwareDecoding;
|
args.variables.ffmpegCommand.hardwareDecoding = hardwareDecoding;
|
||||||
i = 0;
|
i = 0;
|
||||||
_c.label = 1;
|
_d.label = 1;
|
||||||
case 1:
|
case 1:
|
||||||
if (!(i < args.variables.ffmpegCommand.streams.length)) return [3 /*break*/, 4];
|
if (!(i < args.variables.ffmpegCommand.streams.length)) return [3 /*break*/, 4];
|
||||||
stream = args.variables.ffmpegCommand.streams[i];
|
stream = args.variables.ffmpegCommand.streams[i];
|
||||||
if (!(stream.codec_type === 'video')) return [3 /*break*/, 3];
|
if (!(stream.codec_type === 'video')) return [3 /*break*/, 3];
|
||||||
targetCodec = String(args.inputs.outputCodec);
|
targetCodec = String(args.inputs.outputCodec);
|
||||||
|
_a = args.inputs, ffmpegPresetEnabled = _a.ffmpegPresetEnabled, ffmpegQualityEnabled = _a.ffmpegQualityEnabled;
|
||||||
ffmpegPreset = String(args.inputs.ffmpegPreset);
|
ffmpegPreset = String(args.inputs.ffmpegPreset);
|
||||||
ffmpegQuality = String(args.inputs.ffmpegQuality);
|
ffmpegQuality = String(args.inputs.ffmpegQuality);
|
||||||
forceEncoding = args.inputs.forceEncoding === true;
|
forceEncoding = args.inputs.forceEncoding === true;
|
||||||
|
|
@ -191,24 +242,28 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
args: args,
|
args: args,
|
||||||
})];
|
})];
|
||||||
case 2:
|
case 2:
|
||||||
encoderProperties = _c.sent();
|
encoderProperties = _d.sent();
|
||||||
stream.outputArgs.push('-c:{outputIndex}', encoderProperties.encoder);
|
stream.outputArgs.push('-c:{outputIndex}', encoderProperties.encoder);
|
||||||
if (encoderProperties.isGpu) {
|
if (ffmpegQualityEnabled) {
|
||||||
stream.outputArgs.push('-qp', ffmpegQuality);
|
if (encoderProperties.isGpu) {
|
||||||
|
stream.outputArgs.push('-qp', ffmpegQuality);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stream.outputArgs.push('-crf', ffmpegQuality);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (ffmpegPresetEnabled) {
|
||||||
stream.outputArgs.push('-crf', ffmpegQuality);
|
if (targetCodec !== 'av1' && ffmpegPreset) {
|
||||||
}
|
stream.outputArgs.push('-preset', ffmpegPreset);
|
||||||
if (targetCodec !== 'av1' && ffmpegPreset) {
|
}
|
||||||
stream.outputArgs.push('-preset', ffmpegPreset);
|
|
||||||
}
|
}
|
||||||
if (hardwareDecoding) {
|
if (hardwareDecoding) {
|
||||||
(_a = stream.inputArgs).push.apply(_a, encoderProperties.inputArgs);
|
(_b = stream.inputArgs).push.apply(_b, encoderProperties.inputArgs);
|
||||||
}
|
}
|
||||||
if (encoderProperties.outputArgs) {
|
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:
|
case 3:
|
||||||
i += 1;
|
i += 1;
|
||||||
return [3 /*break*/, 1];
|
return [3 /*break*/, 1];
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,16 @@ const details = (): IpluginDetails => ({
|
||||||
},
|
},
|
||||||
tooltip: 'Specify codec of the output file',
|
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',
|
label: 'FFmpeg Preset',
|
||||||
name: 'ffmpegPreset',
|
name: 'ffmpegPreset',
|
||||||
|
|
@ -56,9 +66,34 @@ const details = (): IpluginDetails => ({
|
||||||
'superfast',
|
'superfast',
|
||||||
'ultrafast',
|
'ultrafast',
|
||||||
],
|
],
|
||||||
|
displayConditions: {
|
||||||
|
logic: 'AND',
|
||||||
|
sets: [
|
||||||
|
{
|
||||||
|
logic: 'AND',
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
name: 'ffmpegPresetEnabled',
|
||||||
|
value: 'true',
|
||||||
|
condition: '===',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tooltip: 'Specify ffmpeg preset',
|
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',
|
label: 'FFmpeg Quality',
|
||||||
name: 'ffmpegQuality',
|
name: 'ffmpegQuality',
|
||||||
|
|
@ -66,6 +101,21 @@ const details = (): IpluginDetails => ({
|
||||||
defaultValue: '25',
|
defaultValue: '25',
|
||||||
inputUI: {
|
inputUI: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
displayConditions: {
|
||||||
|
logic: 'AND',
|
||||||
|
sets: [
|
||||||
|
{
|
||||||
|
logic: 'AND',
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
name: 'ffmpegQualityEnabled',
|
||||||
|
value: 'true',
|
||||||
|
condition: '===',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tooltip: 'Specify ffmpeg quality',
|
tooltip: 'Specify ffmpeg quality',
|
||||||
},
|
},
|
||||||
|
|
@ -140,6 +190,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
|
|
||||||
if (stream.codec_type === 'video') {
|
if (stream.codec_type === 'video') {
|
||||||
const targetCodec = String(args.inputs.outputCodec);
|
const targetCodec = String(args.inputs.outputCodec);
|
||||||
|
const { ffmpegPresetEnabled, ffmpegQualityEnabled } = args.inputs;
|
||||||
const ffmpegPreset = String(args.inputs.ffmpegPreset);
|
const ffmpegPreset = String(args.inputs.ffmpegPreset);
|
||||||
const ffmpegQuality = String(args.inputs.ffmpegQuality);
|
const ffmpegQuality = String(args.inputs.ffmpegQuality);
|
||||||
const forceEncoding = args.inputs.forceEncoding === true;
|
const forceEncoding = args.inputs.forceEncoding === true;
|
||||||
|
|
@ -161,14 +212,18 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
|
|
||||||
stream.outputArgs.push('-c:{outputIndex}', encoderProperties.encoder);
|
stream.outputArgs.push('-c:{outputIndex}', encoderProperties.encoder);
|
||||||
|
|
||||||
if (encoderProperties.isGpu) {
|
if (ffmpegQualityEnabled) {
|
||||||
stream.outputArgs.push('-qp', ffmpegQuality);
|
if (encoderProperties.isGpu) {
|
||||||
} else {
|
stream.outputArgs.push('-qp', ffmpegQuality);
|
||||||
stream.outputArgs.push('-crf', ffmpegQuality);
|
} else {
|
||||||
|
stream.outputArgs.push('-crf', ffmpegQuality);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetCodec !== 'av1' && ffmpegPreset) {
|
if (ffmpegPresetEnabled) {
|
||||||
stream.outputArgs.push('-preset', ffmpegPreset);
|
if (targetCodec !== 'av1' && ffmpegPreset) {
|
||||||
|
stream.outputArgs.push('-preset', ffmpegPreset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hardwareDecoding) {
|
if (hardwareDecoding) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue