mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 15:38:19 -07:00
Add forceConform
This commit is contained in:
parent
2ab614f900
commit
9a2d4f7fbc
2 changed files with 104 additions and 2 deletions
|
|
@ -30,6 +30,19 @@ var details = function () { return ({
|
|||
},
|
||||
tooltip: 'Specify the container to use',
|
||||
},
|
||||
{
|
||||
name: 'forceConform',
|
||||
type: 'boolean',
|
||||
defaultValue: 'false',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'false',
|
||||
'true',
|
||||
],
|
||||
},
|
||||
tooltip: "\nSpecify if you want to force conform the file to the new container,\nThis is useful if not all streams are supported by the new container. \nFor example mkv does not support data streams.\n ",
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
|
|
@ -45,9 +58,42 @@ var plugin = function (args) {
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||
var newContainer = String(args.inputs.container);
|
||||
var forceConform = args.inputs.forceConform;
|
||||
if ((0, fileUtils_1.getContainer)(args.inputFileObj._id) !== args.inputs.container) {
|
||||
args.variables.ffmpegCommand.container = newContainer;
|
||||
args.variables.ffmpegCommand.shouldProcess = true;
|
||||
if (forceConform === true) {
|
||||
for (var i = 0; i < args.variables.ffmpegCommand.streams.length; i += 1) {
|
||||
var stream = args.variables.ffmpegCommand.streams[i];
|
||||
try {
|
||||
var codecType = stream.codec_type.toLowerCase();
|
||||
var codecName = stream.codec_name.toLowerCase();
|
||||
if (newContainer === 'mkv') {
|
||||
if (codecType === 'data'
|
||||
|| [
|
||||
'mov_text',
|
||||
'eia_608',
|
||||
'timed_id3',
|
||||
].includes(codecName)) {
|
||||
stream.removed = true;
|
||||
}
|
||||
}
|
||||
if (newContainer === 'mp4') {
|
||||
if ([
|
||||
'hdmv_pgs_subtitle',
|
||||
'eia_608',
|
||||
'timed_id3',
|
||||
'subrip',
|
||||
].includes(codecName)) {
|
||||
stream.removed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
// Error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
outputFileObj: args.inputFileObj,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import {
|
|||
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
|
||||
|
||||
/* eslint-disable no-param-reassign */
|
||||
const details = ():IpluginDetails => ({
|
||||
const details = (): IpluginDetails => ({
|
||||
name: 'Set Container',
|
||||
description: 'Set the container of the output file',
|
||||
style: {
|
||||
|
|
@ -34,6 +34,23 @@ const details = ():IpluginDetails => ({
|
|||
},
|
||||
tooltip: 'Specify the container to use',
|
||||
},
|
||||
{
|
||||
name: 'forceConform',
|
||||
type: 'boolean',
|
||||
defaultValue: 'false',
|
||||
inputUI: {
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
'false',
|
||||
'true',
|
||||
],
|
||||
},
|
||||
tooltip: `
|
||||
Specify if you want to force conform the file to the new container,
|
||||
This is useful if not all streams are supported by the new container.
|
||||
For example mkv does not support data streams.
|
||||
`,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
|
|
@ -44,16 +61,55 @@ const details = ():IpluginDetails => ({
|
|||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const plugin = (args:IpluginInputArgs):IpluginOutputArgs => {
|
||||
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);
|
||||
|
||||
const newContainer = String(args.inputs.container);
|
||||
const { forceConform } = args.inputs;
|
||||
|
||||
if (getContainer(args.inputFileObj._id) !== args.inputs.container) {
|
||||
args.variables.ffmpegCommand.container = newContainer;
|
||||
args.variables.ffmpegCommand.shouldProcess = true;
|
||||
|
||||
if (forceConform === true) {
|
||||
for (let i = 0; i < args.variables.ffmpegCommand.streams.length; i += 1) {
|
||||
const stream = args.variables.ffmpegCommand.streams[i];
|
||||
|
||||
try {
|
||||
const codecType = stream.codec_type.toLowerCase();
|
||||
const codecName = stream.codec_name.toLowerCase();
|
||||
if (newContainer === 'mkv') {
|
||||
if (
|
||||
codecType === 'data'
|
||||
|| [
|
||||
'mov_text',
|
||||
'eia_608',
|
||||
'timed_id3',
|
||||
].includes(codecName)
|
||||
) {
|
||||
stream.removed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (newContainer === 'mp4') {
|
||||
if (
|
||||
[
|
||||
'hdmv_pgs_subtitle',
|
||||
'eia_608',
|
||||
'timed_id3',
|
||||
'subrip',
|
||||
].includes(codecName)
|
||||
) {
|
||||
stream.removed = true;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
// Error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue