mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-19 03:56:25 -07:00
Updates to video loop & darwin support
- Corrected some Mac/Darwin support, incorrect 10 bit options (In future will remove videotoolbox support and split into separate plugin) - Improved video check loops, some logic did seem to not correctly stop when needed & the remove stream option had the wrong syntax so probably wouldn't have worked
This commit is contained in:
parent
8aadba1496
commit
890c2642e1
1 changed files with 133 additions and 118 deletions
|
|
@ -353,10 +353,10 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
|
||||
for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
|
||||
const strstreamType = file.ffProbeData.streams[i].codec_type.toLowerCase();
|
||||
videoIdx = -1;
|
||||
// Check if stream is a video.
|
||||
if (videoIdx === -1 && strstreamType === 'video') {
|
||||
videoIdx = i;
|
||||
if (strstreamType === 'video') {
|
||||
if (file.ffProbeData.streams[i].codec_name !== 'mjpeg'
|
||||
&& file.ffProbeData.streams[i].codec_name !== 'png') {
|
||||
// Try checking file stats using Mediainfo first, then ffprobe.
|
||||
try {
|
||||
videoBR = Number(file.mediaInfo.track[i + 1].BitRate) / 1000;
|
||||
|
|
@ -380,9 +380,15 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
duration = file.meta.Duration;
|
||||
duration = (new Date(`1970-01-01T${duration}Z`).getTime() / 1000) / 60;
|
||||
} else { // If not filled then get duration of video stream and do the same.
|
||||
duration = file.ffProbeData.streams[videoIdx].tags.DURATION;
|
||||
duration = file.ffProbeData.streams[i].tags.DURATION;
|
||||
duration = (new Date(`1970-01-01T${duration}Z`).getTime() / 1000) / 60;
|
||||
}
|
||||
if (videoBR <= 0 || Number.isNaN(videoBR)) {
|
||||
// videoBR not yet valid so Loop
|
||||
} else {
|
||||
break;// Exit loop if videoBR is valid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -532,10 +538,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
// Check if codec of stream is mjpeg/png, if so then remove this "video" stream.
|
||||
// mjpeg/png are usually embedded pictures that can cause havoc with plugins.
|
||||
if (file.ffProbeData.streams[i].codec_name === 'mjpeg' || file.ffProbeData.streams[i].codec_name === 'png') {
|
||||
extraArguments += `-map -v:${videoIdx} `;
|
||||
}
|
||||
|
||||
// Check for HDR in files. If so exit plugin. We assume HDR files have bt2020 color spaces. HDR can be complicated
|
||||
extraArguments += `-map -0:v:${videoIdx} `;
|
||||
} else { // Ensure to only do further checks if video stream is valid for use
|
||||
// Check for HDR in files. If so exit plugin. HDR can be complicated
|
||||
// and some aspects are still unsupported in ffmpeg I believe. Likely we don't want to re-encode anything HDR.
|
||||
if (file.ffProbeData.streams[i].color_space === 'bt2020nc'
|
||||
&& file.ffProbeData.streams[i].color_transfer === 'smpte2084'
|
||||
|
|
@ -618,6 +623,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
|| file.ffProbeData.streams[i].bits_per_raw_sample === '10' || inputs.enable_10bit === true) {
|
||||
main10 = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Increment video index. Needed to keep track of video id in case there is more than one video track.
|
||||
// (i.e png or mjpeg which we would remove at the start of the loop)
|
||||
|
|
@ -661,6 +667,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
}
|
||||
|
||||
// Are we encoding to 10 bit? If so enable correct profile & pixel format.
|
||||
if (os.platform() !== 'darwin') {
|
||||
if (swDecode === true && main10 === true) {
|
||||
// This is used if we have High10 or Main10 is enabled & odd format files.
|
||||
// SW decode and use standard -pix_fmt p010le
|
||||
|
|
@ -676,6 +683,11 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
}
|
||||
response.infoLog += '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n';
|
||||
}
|
||||
} else {
|
||||
// Mac - Video toolbox profile & pixel format
|
||||
extraArguments += '-profile:v 2 -pix_fmt yuv420p10le ';
|
||||
response.infoLog += '10 bit encode enabled. Setting VideoToolBox Profile v2 & 10 bit pixel format \n';
|
||||
}
|
||||
|
||||
// Set bitrateSettings variable using bitrate information calculated earlier.
|
||||
bitrateSettings = `-b:v ${targetBitrate}k -minrate ${minimumBitrate}k `
|
||||
|
|
@ -712,6 +724,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
}
|
||||
} else {
|
||||
switch (os.platform()) {
|
||||
case 'darwin': // Mac OS - Enable videotoolbox instead of QSV
|
||||
response.preset += '-hwaccel videotoolbox';
|
||||
break;
|
||||
case 'linux': // Linux - Full device, should fix child_device_type warnings
|
||||
response.preset += `-hwaccel_output_format qsv
|
||||
-init_hw_device qsv:hw_any,child_device_type=vaapi `;
|
||||
|
|
@ -780,7 +795,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
|
||||
// Only add on for HW decoded formats
|
||||
// VC1 & VP8 are no longer supported on new HW, add cases here if your HW does support
|
||||
if (swDecode !== true) {
|
||||
if (swDecode !== true && os.platform() !== 'darwin') {
|
||||
// Check if -vf cmd has already been used on user input
|
||||
if (inputs.extra_qsv_options.search('-vf scale_qsv') >= 0) {
|
||||
switch (file.video_codec_name) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue