mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 07:29:04 -07:00
Add toggles for preset and quality
This commit is contained in:
parent
27f0f3196b
commit
9ce8ec2713
1 changed files with 61 additions and 6 deletions
|
|
@ -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