diff --git a/Community/Tdarr_Plugin_VP92_VP9_Match_Bitrate_One_Pass.js b/Community/Tdarr_Plugin_VP92_VP9_Match_Bitrate_One_Pass.js index e5bf1af..a364d81 100644 --- a/Community/Tdarr_Plugin_VP92_VP9_Match_Bitrate_One_Pass.js +++ b/Community/Tdarr_Plugin_VP92_VP9_Match_Bitrate_One_Pass.js @@ -1,5 +1,4 @@ /* eslint max-classes-per-file: ["error", 2] */ -// tdarrSkipTest const details = () => ({ id: 'Tdarr_Plugin_VP92_VP9_Match_Bitrate_One_Pass', Stage: 'Pre-processing', @@ -256,6 +255,7 @@ class Configurator { function loopOverStreamsOfType(file, type, method) { let id = 0; for (let i = 0; i < file.ffProbeData.streams.length; i += 1) { + console.log(file.ffProbeData.streams[i].codec_type); if (file.ffProbeData.streams[i].codec_type.toLowerCase() === type) { method(file.ffProbeData.streams[i], id); id += 1; @@ -329,6 +329,7 @@ function buildAudioConfiguration(inputs, file, logger) { if ('tags' in stream) { // Remove unwanted languages if ('language' in stream.tags) { + console.log(stream.tags.language.toLowerCase()); if (languages.indexOf(stream.tags.language.toLowerCase()) === -1) { configuration.AddOutputSetting(`-map -0:a:${id}`); streams_removing += 1; @@ -340,6 +341,7 @@ function buildAudioConfiguration(inputs, file, logger) { } }); + console.log(stream_count, streams_removing); if (stream_count === streams_removing) { logger.AddError( '*** All audio tracks would have been removed, removing all delete entries', diff --git a/tests/Community/Tdarr_Plugin_VP92_VP9_Match_Bitrate_One_Pass.js b/tests/Community/Tdarr_Plugin_VP92_VP9_Match_Bitrate_One_Pass.js new file mode 100644 index 0000000..228ff5c --- /dev/null +++ b/tests/Community/Tdarr_Plugin_VP92_VP9_Match_Bitrate_One_Pass.js @@ -0,0 +1,505 @@ +/* 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: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☒ Transcoding file to VP9\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 27 -threads 64 -speed 2 \n' + + ' -quality good -static-thresh 0 -tile-columns 2 -tile-rows 0 -frame-parallel 0 -row-mt 1 \n' + + ' -aq-mode 0 -g 240 \n' + + ' -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH265_1.json')), + librarySettings: {}, + inputs: {}, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☒ Transcoding file to VP9\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 26 -threads 64 -speed 2 \n' + + ' -quality good -static-thresh 0 -tile-columns 2 -tile-rows 0 -frame-parallel 0 -row-mt 1 \n' + + ' -aq-mode 0 -g 240 \n' + + ' -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.container = 'webm'; + file.ffProbeData.streams[0].codec_name = 'vp9'; + return file; + })(), + librarySettings: {}, + inputs: {}, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☑ File is in proper video format\n' + + '☑ No video processing necessary\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -c:v copy \n -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.container = 'webm'; + file.ffProbeData.streams[0].codec_name = 'vp9'; + file.ffProbeData.streams[1].codec_name = 'opus'; + return file; + })(), + librarySettings: {}, + inputs: {}, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☑ No audio processing necessary\n' + + '☑ File is in proper video format\n' + + '☑ No video processing necessary\n' + + '☑ No subtitle processing necessary\n' + + '☑ No need to process file', + processFile: false, + preset: ',-map 0 -map -0:d -c:v copy \n -c:a copy -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '16', + audio_language: 'eng,und,fre', + audio_commentary: 'true', + subtitle_language: 'eng', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☒ Transcoding file to VP9\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 28 -threads 64 -speed 2 \n' + + ' -quality good -static-thresh 0 -tile-columns 2 -tile-rows 0 -frame-parallel 0 -row-mt 1 \n' + + ' -aq-mode 0 -g 240 \n' + + ' -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.video_resolution = '240p'; + return file; + })(), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '16', + audio_language: 'eng,und,fre', + audio_commentary: 'true', + subtitle_language: 'eng', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☒ Transcoding file to VP9\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 33 -threads 64 -speed 1 \n' + + ' -quality good -static-thresh 0 -tile-columns 0 -tile-rows 0 -frame-parallel 0 -row-mt 1 \n' + + ' -aq-mode 0 -g 240 \n' + + ' -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.video_resolution = '360p'; + return file; + })(), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '16', + audio_language: 'eng,und,fre', + audio_commentary: 'true', + subtitle_language: 'eng', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☒ Transcoding file to VP9\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 32 -threads 64 -speed 1 \n' + + ' -quality good -static-thresh 0 -tile-columns 1 -tile-rows 0 -frame-parallel 0 -row-mt 1 \n' + + ' -aq-mode 0 -g 240 \n' + + ' -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.video_resolution = '480p'; + return file; + })(), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '16', + audio_language: 'eng,und,fre', + audio_commentary: 'true', + subtitle_language: 'eng', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☒ Transcoding file to VP9\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 29 -threads 64 -speed 1 \n' + + ' -quality good -static-thresh 0 -tile-columns 1 -tile-rows 0 -frame-parallel 0 -row-mt 1 \n' + + ' -aq-mode 0 -g 240 \n' + + ' -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.video_resolution = '1080p'; + return file; + })(), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '16', + audio_language: 'eng,und,fre', + audio_commentary: 'true', + subtitle_language: 'eng', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☒ Transcoding file to VP9\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 27 -threads 64 -speed 2 \n' + + ' -quality good -static-thresh 0 -tile-columns 2 -tile-rows 0 -frame-parallel 0 -row-mt 1 \n' + + ' -aq-mode 0 -g 240 \n' + + ' -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.video_resolution = '4KUHD'; + return file; + })(), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '17', + audio_language: 'eng,und,fre', + audio_commentary: 'true', + subtitle_language: 'eng', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☒ Transcoding file to VP9\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 16 -threads 64 -speed 2 \n' + + ' -quality good -static-thresh 0 -tile-columns 3 -tile-rows 0 -frame-parallel 0 -row-mt 1 \n' + + ' -aq-mode 0 -g 240 \n' + + ' -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.video_resolution = '8KUHD'; + return file; + })(), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '17', + audio_language: 'eng,und,fre', + audio_commentary: 'true', + subtitle_language: 'eng', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Audio is not in proper codec, will format\n' + + '☒ Transcoding file to VP9\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 17 -threads 64 -speed 2 \n' + + ' -quality good -static-thresh 0 -tile-columns 3 -tile-rows 0 -frame-parallel 0 -row-mt 1 \n' + + ' -aq-mode 0 -g 240 \n' + + ' -c:a libopus -c:s copy', + reQueueAfter: true, + }, + }, + + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.container = 'webm'; + file.ffProbeData.streams[0].codec_name = 'vp9'; + file.ffProbeData.streams[1].codec_name = 'opus'; + file.ffProbeData.streams[1].tags.language = 'eng'; + + file.ffProbeData.streams[2] = _.cloneDeep(file.ffProbeData.streams[1]); + file.ffProbeData.streams[2].codec_type = 'subtitle'; + file.ffProbeData.streams[2].tags.title = 'commentary'; + return file; + })(), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '17', + audio_language: 'eng,und,fre', + audio_commentary: 'true', + subtitle_language: 'eng,und', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☑ No audio processing necessary\n' + + '☑ File is in proper video format\n' + + '☑ No video processing necessary\n' + + '☒ Removing Commentary or Description subtitle: commentary', + processFile: true, + preset: ',-map 0 -map -0:d -c:v copy \n -c:a copy -c:s copy -map -0:s:0', + reQueueAfter: true, + }, + }, + + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.container = 'webm'; + file.ffProbeData.streams[0].codec_name = 'vp9'; + file.ffProbeData.streams[1].codec_name = 'opus'; + file.ffProbeData.streams[1].tags.language = 'eng'; + + file.ffProbeData.streams[2] = _.cloneDeep(file.ffProbeData.streams[0]); + file.ffProbeData.streams[2].codec_name = 'mjpeg'; + return file; + })(), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '17', + audio_language: 'eng,und,fre', + audio_commentary: 'true', + subtitle_language: 'eng,und', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☑ No audio processing necessary\n' + + '☑ File is in proper video format\n' + + '☒ Removing mjpeg\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -c:v copy -map -0:v:1 \n -c:a copy -c:s copy', + reQueueAfter: true, + }, + }, + { + input: { + file: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.container = 'webm'; + file.ffProbeData.streams[0].codec_name = 'vp9'; + file.ffProbeData.streams[1].codec_name = 'opus'; + file.ffProbeData.streams[1].tags.language = 'eng'; + + file.ffProbeData.streams[2] = _.cloneDeep(file.ffProbeData.streams[1]); + file.ffProbeData.streams[2].tags.language = 'fre'; + return file; + })(), + librarySettings: {}, + inputs: { + CQ_240p: '33', + CQ_360p: '32', + CQ_480p: '29', + CQ_720p: '28', + CQ_1080p: '27', + CQ_4KUHD: '16', + CQ_8KUHD: '17', + audio_language: 'eng,und', + audio_commentary: 'true', + subtitle_language: 'eng,und', + subtitle_commentary: 'true', + remove_mjpeg: 'true', + }, + otherArguments: {}, + }, + output: { + container: '.webm', + FFmpegMode: true, + handBrakeMode: false, + infoLog: '☒ Removing audio track in language fre\n' + + '☑ File is in proper video format\n' + + '☑ No video processing necessary\n' + + '☑ No subtitle processing necessary', + processFile: true, + preset: ',-map 0 -map -0:d -c:v copy \n -c:a copy -map -0:a:1 -c:s copy', + reQueueAfter: true, + }, + }, +]; + +run(tests);