Fixed issue with video files missing language tag on audio track so it

assumes the audio track is a desired audio track. Changed default
target framerate to 30 to prevent issues with videos that have a
framerate of 29.97.
make-only-subtitle-default
Zach Gelnett 2 years ago
parent 9be9a36511
commit bf723c032a

@ -86,7 +86,6 @@ Audio: (Only one audio stream is used!!)
/// /////////////////////////////////////////////////////////////////////////////////////////////////// /// ///////////////////////////////////////////////////////////////////////////////////////////////////
*/ */
// tdarrSkipTest
const details = () => ({ const details = () => ({
id: 'Tdarr_Plugin_JB69_JBHEVCQSV_MinimalFile', id: 'Tdarr_Plugin_JB69_JBHEVCQSV_MinimalFile',
Stage: 'Pre-processing', Stage: 'Pre-processing',
@ -130,7 +129,7 @@ how it works **this does a lot** and is 1 of 2 routines you should to run **Part
}, { }, {
name: 'Target_Framerate', name: 'Target_Framerate',
type: 'number', type: 'number',
defaultValue: 25, defaultValue: 30,
inputUI: { inputUI: {
type: 'text', type: 'text',
}, },
@ -184,7 +183,8 @@ how it works **this does a lot** and is 1 of 2 routines you should to run **Part
inputUI: { inputUI: {
type: 'text', type: 'text',
}, },
tooltip: 'Desired Audio Codec, if you change this it might require code changes.', tooltip: `Desired Audio Codec, if you change this it might require code changes.
\\nMust follow ISO-639-2 3 letter format. https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes`,
}, { }, {
name: 'Target_Audio_Language', name: 'Target_Audio_Language',
type: 'string', type: 'string',
@ -232,11 +232,11 @@ const findMediaInfoItem = (file, index) => {
return -1; return -1;
}; };
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => { const plugin = (file, librarySettings, inputs, otherArguments) => {
// eslint-disable-next-line global-require // eslint-disable-next-line global-require
const lib = require('../methods/lib')(); const lib = require('../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign // eslint-disable-next-line no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details); inputs = lib.loadDefaultValues(inputs, details);
const response = { const response = {
@ -280,7 +280,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
// Audio // Audio
const targetAudioCodec = inputs.Target_Audio_Codec; const targetAudioCodec = inputs.Target_Audio_Codec;
const targetAudioLanguage = inputs.Target_Audio_Language; const targetAudioLanguage = inputs.Target_Audio_Language.split(',');
const targetAudioBitratePerChannel = inputs.Target_Audio_Bitrate_Per_Channel; const targetAudioBitratePerChannel = inputs.Target_Audio_Bitrate_Per_Channel;
const targetAudioChannels = inputs.Target_Audio_Channels; const targetAudioChannels = inputs.Target_Audio_Channels;
@ -337,6 +337,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
try { try {
proc.execSync(`mkvpropedit --add-track-statistics-tags "${currentFileName}"`); proc.execSync(`mkvpropedit --add-track-statistics-tags "${currentFileName}"`);
response.processFile = true;
return response; return response;
} catch (err) { } catch (err) {
response.infoLog += 'Error Updating Status Probably Bad file, A remux will probably fix, will continue\n'; response.infoLog += 'Error Updating Status Probably Bad file, A remux will probably fix, will continue\n';
@ -352,6 +353,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
let videoNewWidth = 0; let videoNewWidth = 0;
let bolSource10bit = false; let bolSource10bit = false;
let bolTranscodeSoftwareDecode = false; let bolTranscodeSoftwareDecode = false;
let bolSoftwareTranscodeOpt = false;
let audioNewChannels = 0; let audioNewChannels = 0;
let bolTranscodeAudio = false; let bolTranscodeAudio = false;
@ -396,15 +398,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
streamBR = file.mediaInfo.track[MILoc].extra.FromStats_BitRate * 1; streamBR = file.mediaInfo.track[MILoc].extra.FromStats_BitRate * 1;
} }
let duration = 0;
if (parseFloat(file.ffProbeData?.format?.duration) > 0) {
duration = parseFloat(file.ffProbeData?.format?.duration);
} else {
duration = file.meta.Duration;
}
response.infoLog response.infoLog
+= `Video stream ${i}:${Math.floor(duration / 60)}:` += `Video stream ${i}:${Math.floor(file.meta.Duration / 60)}:`
+ `${file.ffProbeData.streams[i].codec_name}${(bolSource10bit) ? '(10)' : ''}`; + `${file.ffProbeData.streams[i].codec_name}${(bolSource10bit) ? '(10)' : ''}`;
response.infoLog += `:${streamWidth}x${streamHeight}x${streamFPS}:${streamBR}bps \n`; response.infoLog += `:${streamWidth}x${streamHeight}x${streamFPS}:${streamBR}bps \n`;
@ -442,9 +437,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
audioBitrate = file.mediaInfo.track[findMediaInfoItem(file, i)].extra.FromStats_BitRate * 1; audioBitrate = file.mediaInfo.track[findMediaInfoItem(file, i)].extra.FromStats_BitRate * 1;
} }
if ( if (file.ffProbeData.streams[i].tags !== undefined
file.ffProbeData.streams[i].tags !== undefined && (file.ffProbeData.streams[i].tags?.language === undefined
&& file.ffProbeData.streams[i].tags.language === targetAudioLanguage || targetAudioLanguage.indexOf(file.ffProbeData.streams[i].tags.language.toLowerCase()) >= 0)
) { ) {
response.infoLog response.infoLog
+= `Audio stream ${i}:${targetAudioLanguage}` += `Audio stream ${i}:${targetAudioLanguage}`
@ -716,6 +711,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
} }
let strChangeVideoRateString = ''; let strChangeVideoRateString = '';
// bolChangeFrameRateVideo=false;
if (bolChangeFrameRateVideo) { if (bolChangeFrameRateVideo) {
// Used to change the framerate to the target framerate // Used to change the framerate to the target framerate
strChangeVideoRateString = `fps=${targetFrameRate},`; strChangeVideoRateString = `fps=${targetFrameRate},`;
@ -741,13 +737,16 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
strFormat += ','; strFormat += ',';
} }
// Used to make it sure the software decode is in the proper pixel format // Used to make it sure the software decode is in the proper pixel format
strFormat += 'nv12|vaapi'; strFormat += 'nv12|vaapi,hwupload';
bolSoftwareTranscodeOpt = true;
} }
if (strFormat.length > 0) { if (strFormat.length > 0) {
strFormat += ','; strFormat += ',';
} }
// Used to make it use software decode if necessary if (!bolSoftwareTranscodeOpt) {
strFormat += 'hwupload'; // Used to make it use software decode if necessary
strFormat += 'nv12,hwupload';
}
} }
if (strFormat.length > 0) { if (strFormat.length > 0) {

Loading…
Cancel
Save