You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that every time this plugin ran, all of the attached fonts on the file were deleted. Upon inspection, it seems as though the streams are mapped, but there is no mapping for attachments -map 0:t?. This is of course very bad for a plugin marked as "audio only". I only wish I had caught this bug before it processed thousands of my anime episodes.
For anyone looking to do what I was doing (set an audio track as default based on language, not quite the same as this plugin) and you want a copy-paste solution, this plugin I wrote will set the first audio track it finds in a specified language as default (but it won't change the position of the stream).
/* eslint max-len: 0, no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */constdetails=()=>({id: 'Tdarr_Plugin_gabehf_Make_First_Audio_In_Lang_Default',Stage: 'Pre-processing',Name: 'Make First Audio In The Preferred Language Default',Type: 'Audio',Operation: 'Transcode',Description:
'If no audio in the preferred language are made default already, this plugin sets the first audio stream in that language as default. \\n',Version: '1.0',Tags: 'pre-processing,ffmpeg,audio only,configurable',Inputs: [{name: 'preferred_language',type: 'string',defaultValue: 'jpn',inputUI: {type: 'text',},tooltip:
'Your preferred language code(s) in ISO 639-2 language scheme, separated by a comma. Only the first track that matches any of these language codes will be made default. \\n Default: eng,en',}],});// eslint-disable-next-line @typescript-eslint/no-unused-varsconstplugin=(file,librarySettings,inputs,otherArguments)=>{constlib=require('../methods/lib')();// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassigninputs=lib.loadDefaultValues(inputs,details);varlanguages=[]if(inputs.preferred_language==""){languages=["jpn"];//these languages should be kept, named according to ISO 639-2 language scheme}else{languages=inputs.preferred_language.toLowerCase().split(",");//these languages should be kept, named according to ISO 639-2 language scheme}constresponse={processFile: false,preset: '',container: `.${file.container}`,handBrakeMode: false,FFmpegMode: true,reQueueAfter: false,infoLog: '',};// Check if file is a video. If it isn't then exit plugin.if(file.fileMedium!=='video'){// eslint-disable-next-line no-consoleconsole.log('File is not video');response.infoLog+='☒File is not video \n';response.processFile=false;returnresponse;}// Set up required variables.letffmpegCommandInsert='';letaudioIdx=0;letconvert=false;letdefaults=[]// list of tracks currently set as defaultfor(leti=0;i<file.ffProbeData.streams.length;i++){try{if(file.ffProbeData.streams[i].codec_type.toLowerCase()==='audio'){defaults[audioIdx]=file.ffProbeData.streams[i].disposition.default===1if(!convert&&file.ffProbeData.streams[i].disposition.default===0&&languages.includes(file.ffProbeData.streams[i].tags.language)){convert=true;ffmpegCommandInsert+=`-disposition:a:${audioIdx} default `;response.infoLog+=`☒Audio stream 0:a:${audioIdx} is the first track in preferred language and not currently default; setting as default. \n`;}elseif(file.ffProbeData.streams[i].disposition.default===1&&languages.includes(file.ffProbeData.streams[i].tags.language)){// if any audio with the preferred language is marked default, no action is needed.convert=false;response.infoLog='';break;}audioIdx+=1;}}catch(err){// Error}}if(convert){// remove previous default(s)for(leti=0;i<defaults.length;i++){if(defaults[i]){ffmpegCommandInsert+=`-disposition:a:${i} 0 `;response.infoLog+=`☒Audio stream 0:a:${i} was default but not in preferred language; removing disposition. \n`;}}}// Convert file if convert variable is set to true.if(convert===true){response.processFile=true;response.preset=`, -map 0 ${ffmpegCommandInsert}-c copy -max_muxing_queue_size 9999`;response.container=`.${file.container}`;response.reQueueAfter=true;}else{response.processFile=false;response.infoLog+="☑File doesn't contain audio tracks that require modification.\n";}returnresponse;};module.exports.details=details;module.exports.plugin=plugin;
The text was updated successfully, but these errors were encountered:
I noticed that every time this plugin ran, all of the attached fonts on the file were deleted. Upon inspection, it seems as though the streams are mapped, but there is no mapping for attachments
-map 0:t?
. This is of course very bad for a plugin marked as "audio only". I only wish I had caught this bug before it processed thousands of my anime episodes.For anyone looking to do what I was doing (set an audio track as default based on language, not quite the same as this plugin) and you want a copy-paste solution, this plugin I wrote will set the first audio track it finds in a specified language as default (but it won't change the position of the stream).
The text was updated successfully, but these errors were encountered: