Tdarr_Plugins/FlowPluginsTs/CommunityFlowPlugins/video/checkHdr/1.0.0/index.ts
clifford64 c372a21883
Update index.ts
Current implementation is looking for "transfer_characteristics" within ffprobe data as an attribute that has to match to determine if a file is HDR or not. However, current ffprobe is not showing this attribute on HDR files. I am proposing changing this attribute to "color_transfer" which does show up on HDR files.
2023-09-05 16:34:09 -04:00

66 lines
1.6 KiB
TypeScript

import {
IpluginDetails,
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({
name: 'Check HDR Video',
description: 'Check if video is HDR',
style: {
borderColor: 'orange',
},
tags: 'video',
isStartPlugin: false,
pType: '',
requiresVersion: '2.11.01',
sidebarPosition: -1,
icon: 'faQuestion',
inputs: [],
outputs: [
{
number: 1,
tooltip: 'File is HDR',
},
{
number: 2,
tooltip: 'File is not HDR',
},
],
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
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);
let isHdr = false;
if (Array.isArray(args?.inputFileObj?.ffProbeData?.streams)) {
for (let i = 0; i < args.inputFileObj.ffProbeData.streams.length; i += 1) {
const stream = args.inputFileObj.ffProbeData.streams[i];
if (
stream.codec_type === 'video'
&& stream.color_transfer === 'smpte2084'
&& stream.color_primaries === 'bt2020'
&& stream.color_range === 'tv'
) {
isHdr = true;
}
}
} else {
throw new Error('File has not stream data');
}
return {
outputFileObj: args.inputFileObj,
outputNumber: isHdr ? 1 : 2,
variables: args.variables,
};
};
export {
details,
plugin,
};