Merge pull request #285 from aunefyren/master
Music library plugin, Audio to FLACmake-only-subtitle-default
commit
db3fecab6a
@ -0,0 +1,79 @@
|
|||||||
|
const details = () => ({
|
||||||
|
id: 'Tdarr_Plugin_f4k1_aune_audio_to_flac',
|
||||||
|
Stage: 'Pre-processing',
|
||||||
|
Name: 'Aune - Audio to FLAC',
|
||||||
|
Type: 'Audio',
|
||||||
|
Operation: 'Transcode',
|
||||||
|
Description: 'This plugin transcodes different audio codecs to FLAC. '
|
||||||
|
+ 'Leaving the default inputs results in lossless conversion as ALAC and'
|
||||||
|
+ ' PCM codecs don\'t require transcoding for FLAC. It ignores files that'
|
||||||
|
+ ' contains video streams and is made for music libraries.\n\n',
|
||||||
|
Version: '1.00',
|
||||||
|
Tags: 'pre-processing,ffmpeg,audio only',
|
||||||
|
Inputs: [
|
||||||
|
{
|
||||||
|
name: 'codecs',
|
||||||
|
type: 'string',
|
||||||
|
defaultValue: 'alac,pcm_s16be,pcm_s16le,pcm_s24be,pcm_s24le,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le',
|
||||||
|
inputUI: {
|
||||||
|
type: 'text',
|
||||||
|
},
|
||||||
|
tooltip:
|
||||||
|
`Select the codec(s) (comma seperated) you would like to transcode to FLAC.
|
||||||
|
\\nExample:\\n
|
||||||
|
alac
|
||||||
|
\\nExample:\\n
|
||||||
|
alac, pcm_s16be, mp3
|
||||||
|
\\nExample:\\n
|
||||||
|
alac,pcm_s16be,pcm_s16le,pcm_s24be,pcm_s24le,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
|
const lib = require('../methods/lib')();
|
||||||
|
// eslint-disable-next-line no-unused-vars,no-param-reassign
|
||||||
|
inputs = lib.loadDefaultValues(inputs, details);
|
||||||
|
|
||||||
|
const response = {
|
||||||
|
processFile: false,
|
||||||
|
preset: '<io> -c:a flac -f flac',
|
||||||
|
container: '.flac',
|
||||||
|
handBrakeMode: false,
|
||||||
|
FFmpegMode: true,
|
||||||
|
reQueueAfter: true,
|
||||||
|
infoLog: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
if (inputs.codecs === '' || inputs.codecs === undefined) {
|
||||||
|
response.infoLog += '☒No codecs selected!\n';
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
inputs.codecs = inputs.codecs.split(',');
|
||||||
|
|
||||||
|
if (file.ffProbeData.streams.filter((x) => x.codec_type === 'video' && x.avg_frame_rate !== '0/0').length) {
|
||||||
|
response.infoLog += '☒File contains video!\n';
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Either transcode to FLAC or ignore file
|
||||||
|
for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
|
||||||
|
for (let j = 0; j < inputs.codecs.length; j += 1) {
|
||||||
|
if (
|
||||||
|
file.ffProbeData.streams[i].codec_type === 'audio'
|
||||||
|
&& file.ffProbeData.streams[i].codec_name.toLowerCase() === inputs.codecs[j].toLowerCase().trim()
|
||||||
|
) {
|
||||||
|
response.processFile = true;
|
||||||
|
response.infoLog += `☒Found ${inputs.codecs[j].toLowerCase().trim()} codec!\n`;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.infoLog += '☑No matching codecs found!\n';
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.details = details;
|
||||||
|
module.exports.plugin = plugin;
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
/* eslint max-len: 0 */
|
||||||
|
const _ = require('lodash');
|
||||||
|
const run = require('../helpers/run');
|
||||||
|
|
||||||
|
const tests = [
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {},
|
||||||
|
otherArguments: {},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
processFile: false,
|
||||||
|
preset: '<io> -c:a flac -f flac',
|
||||||
|
container: '.flac',
|
||||||
|
handBrakeMode: false,
|
||||||
|
FFmpegMode: true,
|
||||||
|
reQueueAfter: true,
|
||||||
|
infoLog: '☒File contains video!\n',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: _.cloneDeep(require('../sampleData/media/sampleMP3_1.json')),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {},
|
||||||
|
otherArguments: {},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
processFile: false,
|
||||||
|
preset: '<io> -c:a flac -f flac',
|
||||||
|
container: '.flac',
|
||||||
|
handBrakeMode: false,
|
||||||
|
FFmpegMode: true,
|
||||||
|
reQueueAfter: true,
|
||||||
|
infoLog: '☑No matching codecs found!\n',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: _.cloneDeep(require('../sampleData/media/sampleMP3_1.json')),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {
|
||||||
|
codecs: 'mp3',
|
||||||
|
},
|
||||||
|
otherArguments: {},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
processFile: true,
|
||||||
|
preset: '<io> -c:a flac -f flac',
|
||||||
|
container: '.flac',
|
||||||
|
handBrakeMode: false,
|
||||||
|
FFmpegMode: true,
|
||||||
|
reQueueAfter: true,
|
||||||
|
infoLog: '☒Found mp3 codec!\n',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: (() => {
|
||||||
|
const file = _.cloneDeep(require('../sampleData/media/sampleH264_2.json'));
|
||||||
|
// mock audio file with multiple streams
|
||||||
|
file.ffProbeData.streams[0].codec_type = 'audio';
|
||||||
|
return file;
|
||||||
|
})(),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {
|
||||||
|
codecs: 'ac3,eac3,aac',
|
||||||
|
},
|
||||||
|
otherArguments: {},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
processFile: true,
|
||||||
|
preset: '<io> -c:a flac -f flac',
|
||||||
|
container: '.flac',
|
||||||
|
handBrakeMode: false,
|
||||||
|
FFmpegMode: true,
|
||||||
|
reQueueAfter: true,
|
||||||
|
infoLog: '☒Found ac3 codec!\n',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
run(tests);
|
||||||
Loading…
Reference in new issue