mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-16 02:35:54 -07:00
Update Tdarr_Plugin_bsh1_Boosh_FFMPEG_QSV_HEVC.js
New fix for HW decode. H264 High10 is the problem. Enable SW decode for that and normal HW decode on the rest.
This commit is contained in:
parent
a48b35f04c
commit
3ac61410a0
1 changed files with 22 additions and 18 deletions
|
|
@ -329,6 +329,7 @@ let extraArguments = '';
|
||||||
let bitrateSettings = '';
|
let bitrateSettings = '';
|
||||||
let inflatedCutoff = 0;
|
let inflatedCutoff = 0;
|
||||||
let main10 = false;
|
let main10 = false;
|
||||||
|
let high10 = false;
|
||||||
let videoBR = 0;
|
let videoBR = 0;
|
||||||
|
|
||||||
// Finds the first video stream and get video bitrate
|
// Finds the first video stream and get video bitrate
|
||||||
|
|
@ -602,14 +603,6 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we encoding to 10 bit? If so enable correct profile & pixel format.
|
|
||||||
// With this set we also disable hardware decode for compatibility later
|
|
||||||
if (inputs.enable_10bit === true) {
|
|
||||||
main10 = true;
|
|
||||||
extraArguments += '-profile:v main10 -vf scale_qsv=format=p010le ';
|
|
||||||
response.infoLog += '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Go through each stream in the file.
|
// Go through each stream in the file.
|
||||||
for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
|
for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
|
||||||
// Check if stream is a video.
|
// Check if stream is a video.
|
||||||
|
|
@ -700,13 +693,15 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If files are already 10bit then disable hardware decode to avoid problems with encode
|
// On testing I've found files in the High10 profile don't play nice with hw decoding so mark these
|
||||||
// 10 bit from source file should be retained without extra arguments.
|
if (file.ffProbeData.streams[i].profile === 'High 10') {
|
||||||
if (file.ffProbeData.streams[i].profile === 'High 10'
|
high10 = true;
|
||||||
|| file.ffProbeData.streams[i].profile === 'Main 10'
|
response.infoLog += 'Input file is 10bit using High10. Disabling hardware decoding to avoid problems. \n';
|
||||||
|| file.ffProbeData.streams[i].bits_per_raw_sample === '10') {
|
}
|
||||||
|
// If files are 10 bit or the enable_10bit setting is used mark to enable Main10.
|
||||||
|
if (file.ffProbeData.streams[i].profile === 'Main 10' || file.ffProbeData.streams[i].bits_per_raw_sample === '10'
|
||||||
|
|| inputs.enable_10bit === true) {
|
||||||
main10 = true;
|
main10 = true;
|
||||||
response.infoLog += 'Input file is 10bit. Disabling hardware decoding to avoid problems. \n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment video index. Needed to keep track of video id in case there is more than one video track.
|
// Increment video index. Needed to keep track of video id in case there is more than one video track.
|
||||||
|
|
@ -715,6 +710,15 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Are we encoding to 10 bit? If so enable correct profile & pixel format.
|
||||||
|
if (high10 === true) { // This is used if we have High10 files. SW decode and use standard -pix_fmt p010le
|
||||||
|
extraArguments += '-profile:v main10 -pix_fmt p010le ';
|
||||||
|
response.infoLog += '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n';
|
||||||
|
} else if (main10 === true) { // Pixel formate method when using HW decode
|
||||||
|
extraArguments += '-profile:v main10 -vf scale_qsv=format=p010le ';
|
||||||
|
response.infoLog += '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n';
|
||||||
|
}
|
||||||
|
|
||||||
// Set bitrateSettings variable using bitrate information calculated earlier.
|
// Set bitrateSettings variable using bitrate information calculated earlier.
|
||||||
bitrateSettings = `-b:v ${targetBitrate}k -minrate ${minimumBitrate}k `
|
bitrateSettings = `-b:v ${targetBitrate}k -minrate ${minimumBitrate}k `
|
||||||
+ `-maxrate ${maximumBitrate}k -bufsize ${currentBitrate}k`;
|
+ `-maxrate ${maximumBitrate}k -bufsize ${currentBitrate}k`;
|
||||||
|
|
@ -729,10 +733,10 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
// -fflags +genpts should regenerate timestamps if they end up missing...
|
// -fflags +genpts should regenerate timestamps if they end up missing...
|
||||||
response.preset = '-fflags +genpts ';
|
response.preset = '-fflags +genpts ';
|
||||||
|
|
||||||
// HW ACCEL FLAGS
|
// HW ACCEL FLAGS - I think these are good practice but are they necessary?
|
||||||
// Account for different OS
|
// Account for different OS
|
||||||
if (main10 === false) {
|
if (high10 === false) {
|
||||||
// On testing it seems the below will automatically enable hardware decoding which causes issues...
|
// Seems incoming High10 files don't play nice decoding so use software decode
|
||||||
switch (os.platform()) {
|
switch (os.platform()) {
|
||||||
case 'darwin': // Mac OS - Enable videotoolbox instead of QSV
|
case 'darwin': // Mac OS - Enable videotoolbox instead of QSV
|
||||||
response.preset += '-hwaccel videotoolbox';
|
response.preset += '-hwaccel videotoolbox';
|
||||||
|
|
@ -752,7 +756,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
|
|
||||||
// DECODE FLAGS
|
// DECODE FLAGS
|
||||||
if (os.platform() !== 'darwin') {
|
if (os.platform() !== 'darwin') {
|
||||||
if (main10 === false) { // Don't enable if 10bit is on - Seems to cause issues, may need different decode flags
|
if (high10 === false) { // Don't enable for High10
|
||||||
switch (file.video_codec_name) {
|
switch (file.video_codec_name) {
|
||||||
case 'mpeg2':
|
case 'mpeg2':
|
||||||
response.preset += '-c:v mpeg2_qsv';
|
response.preset += '-c:v mpeg2_qsv';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue