|
|
|
@ -10,10 +10,14 @@ const details = () => ({
|
|
|
|
Tags: 'pre-processing,ffmpeg,audio only,configurable',
|
|
|
|
Tags: 'pre-processing,ffmpeg,audio only,configurable',
|
|
|
|
Inputs: [{
|
|
|
|
Inputs: [{
|
|
|
|
name: 'aac_stereo',
|
|
|
|
name: 'aac_stereo',
|
|
|
|
type: 'string',
|
|
|
|
type: 'boolean',
|
|
|
|
defaultValue: '',
|
|
|
|
defaultValue: false,
|
|
|
|
inputUI: {
|
|
|
|
inputUI: {
|
|
|
|
type: 'text',
|
|
|
|
type: 'dropdown',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
'false',
|
|
|
|
|
|
|
|
'true',
|
|
|
|
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tooltip: `Specify if any 2.0 audio tracks should be converted to aac for maximum compatability with devices.
|
|
|
|
tooltip: `Specify if any 2.0 audio tracks should be converted to aac for maximum compatability with devices.
|
|
|
|
\\nOptional.
|
|
|
|
\\nOptional.
|
|
|
|
@ -25,10 +29,14 @@ const details = () => ({
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: 'downmix',
|
|
|
|
name: 'downmix',
|
|
|
|
type: 'string',
|
|
|
|
type: 'boolean',
|
|
|
|
defaultValue: '',
|
|
|
|
defaultValue: false,
|
|
|
|
inputUI: {
|
|
|
|
inputUI: {
|
|
|
|
type: 'text',
|
|
|
|
type: 'dropdown',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
'false',
|
|
|
|
|
|
|
|
'true',
|
|
|
|
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tooltip: `Specify if downmixing should be used to create extra audio tracks.
|
|
|
|
tooltip: `Specify if downmixing should be used to create extra audio tracks.
|
|
|
|
\\nI.e if you have an 8ch but no 2ch or 6ch, create the missing audio tracks from the 8 ch.
|
|
|
|
\\nI.e if you have an 8ch but no 2ch or 6ch, create the missing audio tracks from the 8 ch.
|
|
|
|
@ -39,6 +47,21 @@ const details = () => ({
|
|
|
|
\\nExample:\\n
|
|
|
|
\\nExample:\\n
|
|
|
|
false`,
|
|
|
|
false`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: 'downmix_single_track',
|
|
|
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
|
|
|
defaultValue: false,
|
|
|
|
|
|
|
|
inputUI: {
|
|
|
|
|
|
|
|
type: 'dropdown',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
'false',
|
|
|
|
|
|
|
|
'true',
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
tooltip: 'By default this plugin will downmix each track. '
|
|
|
|
|
|
|
|
+ 'So four 6 channel tracks will result in four 2 channel tracks.'
|
|
|
|
|
|
|
|
+ ' Enable this option to only downmix a single track.',
|
|
|
|
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -77,8 +100,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|
|
|
let audioIdx = 0;
|
|
|
|
let audioIdx = 0;
|
|
|
|
let has2Channel = false;
|
|
|
|
let has2Channel = false;
|
|
|
|
let has6Channel = false;
|
|
|
|
let has6Channel = false;
|
|
|
|
let has8Channel = false;
|
|
|
|
|
|
|
|
let convert = false;
|
|
|
|
let convert = false;
|
|
|
|
|
|
|
|
let is2channelAdded = false;
|
|
|
|
|
|
|
|
let is6channelAdded = false;
|
|
|
|
|
|
|
|
|
|
|
|
// Go through each stream in the file.
|
|
|
|
// Go through each stream in the file.
|
|
|
|
for (let i = 0; i < file.ffProbeData.streams.length; i++) {
|
|
|
|
for (let i = 0; i < file.ffProbeData.streams.length; i++) {
|
|
|
|
@ -91,9 +115,6 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|
|
|
if (file.ffProbeData.streams[i].channels === 6) {
|
|
|
|
if (file.ffProbeData.streams[i].channels === 6) {
|
|
|
|
has6Channel = true;
|
|
|
|
has6Channel = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (file.ffProbeData.streams[i].channels === 8) {
|
|
|
|
|
|
|
|
has8Channel = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
// Error
|
|
|
|
// Error
|
|
|
|
@ -107,26 +128,31 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|
|
|
// Catch error here incase user left inputs.downmix empty.
|
|
|
|
// Catch error here incase user left inputs.downmix empty.
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Check if inputs.downmix is set to true.
|
|
|
|
// Check if inputs.downmix is set to true.
|
|
|
|
if (inputs.downmix.toLowerCase() === 'true') {
|
|
|
|
if (inputs.downmix === true) {
|
|
|
|
// Check if file has 8 channel audio but no 6 channel, if so then create extra downmix from the 8 channel.
|
|
|
|
// Check if file has 8 channel audio but no 6 channel, if so then create extra downmix from the 8 channel.
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
has8Channel === true
|
|
|
|
file.ffProbeData.streams[i].channels === 8
|
|
|
|
&& has6Channel === false
|
|
|
|
&& has6Channel === false
|
|
|
|
&& file.ffProbeData.streams[i].channels === 8
|
|
|
|
&& (inputs.downmix_single_track === false
|
|
|
|
|
|
|
|
|| (inputs.downmix_single_track === true && is6channelAdded === false))
|
|
|
|
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
ffmpegCommandInsert += `-map 0:${i} -c:a:${audioIdx} ac3 -ac 6 -metadata:s:a:${audioIdx} title="5.1" `;
|
|
|
|
ffmpegCommandInsert += `-map 0:${i} -c:a:${audioIdx} ac3 -ac 6 -metadata:s:a:${audioIdx} title="5.1" `;
|
|
|
|
response.infoLog += '☒Audio track is 8 channel, no 6 channel exists. Creating 6 channel from 8 channel. \n';
|
|
|
|
response.infoLog += '☒Audio track is 8 channel, no 6 channel exists. Creating 6 channel from 8 channel. \n';
|
|
|
|
convert = true;
|
|
|
|
convert = true;
|
|
|
|
|
|
|
|
is6channelAdded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Check if file has 6 channel audio but no 2 channel, if so then create extra downmix from the 6 channel.
|
|
|
|
// Check if file has 6 channel audio but no 2 channel, if so then create extra downmix from the 6 channel.
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
has6Channel === true
|
|
|
|
file.ffProbeData.streams[i].channels === 6
|
|
|
|
&& has2Channel === false
|
|
|
|
&& has2Channel === false
|
|
|
|
&& file.ffProbeData.streams[i].channels === 6
|
|
|
|
&& (inputs.downmix_single_track === false
|
|
|
|
|
|
|
|
|| (inputs.downmix_single_track === true && is2channelAdded === false))
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
ffmpegCommandInsert += `-map 0:${i} -c:a:${audioIdx} aac -ac 2 -metadata:s:a:${audioIdx} title="2.0" `;
|
|
|
|
ffmpegCommandInsert += `-map 0:${i} -c:a:${audioIdx} aac -ac 2 -metadata:s:a:${audioIdx} title="2.0" `;
|
|
|
|
response.infoLog += '☒Audio track is 6 channel, no 2 channel exists. Creating 2 channel from 6 channel. \n';
|
|
|
|
response.infoLog += '☒Audio track is 6 channel, no 2 channel exists. Creating 2 channel from 6 channel. \n';
|
|
|
|
convert = true;
|
|
|
|
convert = true;
|
|
|
|
|
|
|
|
is2channelAdded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
@ -136,7 +162,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|
|
|
// Catch error here incase user left inputs.downmix empty.
|
|
|
|
// Catch error here incase user left inputs.downmix empty.
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Check if inputs.aac_stereo is set to true.
|
|
|
|
// Check if inputs.aac_stereo is set to true.
|
|
|
|
if (inputs.aac_stereo === 'true') {
|
|
|
|
if (inputs.aac_stereo === true) {
|
|
|
|
// Check if codec_name for stream is NOT aac AND check if channel ammount is 2.
|
|
|
|
// Check if codec_name for stream is NOT aac AND check if channel ammount is 2.
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
file.ffProbeData.streams[i].codec_name !== 'aac'
|
|
|
|
file.ffProbeData.streams[i].codec_name !== 'aac'
|
|
|
|
|