mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 07:29:04 -07:00
Merge pull request #502 from Boosh1/HWDecodeFix
Fix for HW decode & High10 - Tdarr_Plugin_bsh1_Boosh_FFMPEG_QSV_HEVC.js
This commit is contained in:
commit
d9f7f315f7
2 changed files with 27 additions and 21 deletions
|
|
@ -329,6 +329,7 @@ let extraArguments = '';
|
|||
let bitrateSettings = '';
|
||||
let inflatedCutoff = 0;
|
||||
let main10 = false;
|
||||
let high10 = false;
|
||||
let videoBR = 0;
|
||||
|
||||
// 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.
|
||||
for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
|
||||
// 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
|
||||
// 10 bit from source file should be retained without extra arguments.
|
||||
if (file.ffProbeData.streams[i].profile === 'High 10'
|
||||
|| file.ffProbeData.streams[i].profile === 'Main 10'
|
||||
|| file.ffProbeData.streams[i].bits_per_raw_sample === '10') {
|
||||
// On testing I've found files in the High10 profile don't play nice with hw decoding so mark these
|
||||
if (file.ffProbeData.streams[i].profile === 'High 10') {
|
||||
high10 = true;
|
||||
response.infoLog += 'Input file is 10bit using High10. Disabling hardware decoding to avoid problems. \n';
|
||||
}
|
||||
// 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;
|
||||
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.
|
||||
|
|
@ -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.
|
||||
bitrateSettings = `-b:v ${targetBitrate}k -minrate ${minimumBitrate}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...
|
||||
response.preset = '-fflags +genpts ';
|
||||
|
||||
// HW ACCEL FLAGS
|
||||
// HW ACCEL FLAGS - I think these are good practice but are they necessary?
|
||||
// Account for different OS
|
||||
if (main10 === false) {
|
||||
// On testing it seems the below will automatically enable hardware decoding which causes issues...
|
||||
if (high10 === false) {
|
||||
// Seems incoming High10 files don't play nice decoding so use software decode
|
||||
switch (os.platform()) {
|
||||
case 'darwin': // Mac OS - Enable videotoolbox instead of QSV
|
||||
response.preset += '-hwaccel videotoolbox';
|
||||
|
|
@ -752,7 +756,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
|||
|
||||
// DECODE FLAGS
|
||||
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) {
|
||||
case 'mpeg2':
|
||||
response.preset += '-c:v mpeg2_qsv';
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ const tests = [
|
|||
output: {
|
||||
linux: {
|
||||
processFile: true,
|
||||
preset: '-fflags +genpts <io> -map 0 -c:v hevc_qsv -b:v 603k -minrate 452k -maxrate 754k -bufsize 1206k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -profile:v main10 -vf scale_qsv=format=p010le ',
|
||||
preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n'
|
||||
+ ' -init_hw_device qsv:hw_any,child_device_type=vaapi -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -b:v 603k -minrate 452k -maxrate 754k -bufsize 1206k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -profile:v main10 -vf scale_qsv=format=p010le ',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: true,
|
||||
|
|
@ -96,7 +97,8 @@ const tests = [
|
|||
},
|
||||
win32: {
|
||||
processFile: true,
|
||||
preset: '-fflags +genpts <io> -map 0 -c:v hevc_qsv -load_plugin hevc_hw -b:v 603k -minrate 452k -maxrate 754k -bufsize 1206k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -profile:v main10 -vf scale_qsv=format=p010le ',
|
||||
preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n'
|
||||
+ ' -init_hw_device qsv:hw_any,child_device_type=d3d11va -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -load_plugin hevc_hw -b:v 603k -minrate 452k -maxrate 754k -bufsize 1206k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -profile:v main10 -vf scale_qsv=format=p010le ',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: true,
|
||||
|
|
@ -113,7 +115,7 @@ const tests = [
|
|||
},
|
||||
darwin: {
|
||||
processFile: true,
|
||||
preset: '-fflags +genpts <io> -map 0 -c:v hevc_videotoolbox -b:v 603k -minrate 452k -maxrate 754k -bufsize 1206k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -profile:v main10 -vf scale_qsv=format=p010le ',
|
||||
preset: '-fflags +genpts -hwaccel videotoolbox<io> -map 0 -c:v hevc_videotoolbox -b:v 603k -minrate 452k -maxrate 754k -bufsize 1206k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -profile:v main10 -vf scale_qsv=format=p010le ',
|
||||
handBrakeMode: false,
|
||||
FFmpegMode: true,
|
||||
reQueueAfter: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue