mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-14 01:36:08 -07:00
Merge pull request #315 from HaveAGitGat/v2_change
Update re-ordering of mp4 files
This commit is contained in:
commit
b13151d042
2 changed files with 103 additions and 3 deletions
|
|
@ -102,6 +102,18 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
+ 'This may be due to a corrupt file or permissions issue when scanning the file.');
|
+ 'This may be due to a corrupt file or permissions issue when scanning the file.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file.container === 'mp4' && file.fileMedium === 'video') {
|
||||||
|
if (file.ffProbeData.streams[0].codec_type === 'video') {
|
||||||
|
response.infoLog += 'File is mp4 and already has the video stream in the correct order!'
|
||||||
|
+ ' Due to FFmpeg issues when reordering streams in mp4 files, other stream ordering will be skipped';
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
response.processFile = true;
|
||||||
|
response.infoLog += 'File is mp4 and contains video but video is not first stream, remuxing';
|
||||||
|
response.preset = ',-map 0:v? -map 0:a? -map 0:s? -map 0:d? -map 0:t? -c copy';
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
let { streams } = JSON.parse(JSON.stringify(file.ffProbeData));
|
let { streams } = JSON.parse(JSON.stringify(file.ffProbeData));
|
||||||
|
|
||||||
streams.forEach((stream, index) => {
|
streams.forEach((stream, index) => {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
/* eslint max-len: 0 */
|
/* eslint max-len: 0 */
|
||||||
|
const _ = require('lodash');
|
||||||
const run = require('../helpers/run');
|
const run = require('../helpers/run');
|
||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
{
|
{
|
||||||
input: {
|
input: {
|
||||||
file: require('../sampleData/media/sampleH264_1.json'),
|
file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')),
|
||||||
librarySettings: {},
|
librarySettings: {},
|
||||||
inputs: {},
|
inputs: {},
|
||||||
otherArguments: {},
|
otherArguments: {},
|
||||||
|
|
@ -15,7 +16,7 @@ const tests = [
|
||||||
container: '.mp4',
|
container: '.mp4',
|
||||||
handBrakeMode: false,
|
handBrakeMode: false,
|
||||||
FFmpegMode: true,
|
FFmpegMode: true,
|
||||||
infoLog: 'Streams are in the correct order!',
|
infoLog: 'File is mp4 and already has the video stream in the correct order! Due to FFmpeg issues when reordering streams in mp4 files, other stream ordering will be skipped',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -47,7 +48,7 @@ const tests = [
|
||||||
// }))
|
// }))
|
||||||
|
|
||||||
input: {
|
input: {
|
||||||
file: require('../sampleData/media/sampleH264_2.json'),
|
file: _.cloneDeep(require('../sampleData/media/sampleH264_2.json')),
|
||||||
librarySettings: {},
|
librarySettings: {},
|
||||||
inputs: {
|
inputs: {
|
||||||
processOrder: 'codecs,channels,languages,streamTypes',
|
processOrder: 'codecs,channels,languages,streamTypes',
|
||||||
|
|
@ -67,6 +68,93 @@ const tests = [
|
||||||
infoLog: 'Streams are not in the correct order!',
|
infoLog: 'Streams are not in the correct order!',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: (() => {
|
||||||
|
const file = _.cloneDeep(require('../sampleData/media/sampleH264_2.json'));
|
||||||
|
const s4 = file.ffProbeData.streams[4];
|
||||||
|
|
||||||
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
file.ffProbeData.streams[4] = file.ffProbeData.streams[5];
|
||||||
|
file.ffProbeData.streams[5] = s4;
|
||||||
|
return file;
|
||||||
|
})(),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {
|
||||||
|
processOrder: 'codecs,channels,languages,streamTypes',
|
||||||
|
languages: 'eng,fre',
|
||||||
|
streamTypes: 'video,audio,subtitle',
|
||||||
|
codecs: 'flac,ac3,eac3,aac',
|
||||||
|
channels: '7.1,5.1,2,1',
|
||||||
|
},
|
||||||
|
otherArguments: {},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
processFile: false,
|
||||||
|
preset: '',
|
||||||
|
container: '.mkv',
|
||||||
|
handBrakeMode: false,
|
||||||
|
FFmpegMode: true,
|
||||||
|
infoLog: 'Streams are in the correct order!',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: (() => {
|
||||||
|
const file = _.cloneDeep(require('../sampleData/media/sampleH264_2.json'));
|
||||||
|
file.container = 'mp4';
|
||||||
|
return file;
|
||||||
|
})(),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {
|
||||||
|
processOrder: 'codecs,channels,languages,streamTypes',
|
||||||
|
languages: 'fre,eng',
|
||||||
|
streamTypes: 'video,audio,subtitle',
|
||||||
|
codecs: 'ac3,flac,eac3,aac',
|
||||||
|
channels: '7.1,5.1,2,1',
|
||||||
|
},
|
||||||
|
otherArguments: {},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
processFile: false,
|
||||||
|
preset: '',
|
||||||
|
container: '.mp4',
|
||||||
|
handBrakeMode: false,
|
||||||
|
FFmpegMode: true,
|
||||||
|
infoLog: 'File is mp4 and already has the video stream in the correct order! Due to FFmpeg issues when reordering streams in mp4 files, other stream ordering will be skipped',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: (() => {
|
||||||
|
const file = _.cloneDeep(require('../sampleData/media/sampleH264_2.json'));
|
||||||
|
const s0 = file.ffProbeData.streams[0];
|
||||||
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
file.ffProbeData.streams[0] = file.ffProbeData.streams[1];
|
||||||
|
file.ffProbeData.streams[1] = s0;
|
||||||
|
file.container = 'mp4';
|
||||||
|
return file;
|
||||||
|
})(),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {
|
||||||
|
processOrder: 'codecs,channels,languages,streamTypes',
|
||||||
|
languages: 'fre,eng',
|
||||||
|
streamTypes: 'video,audio,subtitle',
|
||||||
|
codecs: 'ac3,flac,eac3,aac',
|
||||||
|
channels: '7.1,5.1,2,1',
|
||||||
|
},
|
||||||
|
otherArguments: {},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
processFile: true,
|
||||||
|
preset: ',-map 0:v? -map 0:a? -map 0:s? -map 0:d? -map 0:t? -c copy',
|
||||||
|
container: '.mp4',
|
||||||
|
handBrakeMode: false,
|
||||||
|
FFmpegMode: true,
|
||||||
|
infoLog: 'File is mp4 and contains video but video is not first stream, remuxing',
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
run(tests);
|
run(tests);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue