Corrected -vf cmd so it's added on the end better

make-only-subtitle-default
Boosh1 2 years ago
parent 0c925ded51
commit a5dc4934ee

@ -166,6 +166,7 @@ const details = () => ({
\\nDefault is empty but the first example below has a suggested value. If unsure just leave empty. \\nDefault is empty but the first example below has a suggested value. If unsure just leave empty.
\\nEnsure to only use cmds valid to encoding QSV as the script handles other ffmpeg cmds relating to \\nEnsure to only use cmds valid to encoding QSV as the script handles other ffmpeg cmds relating to
bitrate etc. Anything else entered here might be supported but could cause undesired results. bitrate etc. Anything else entered here might be supported but could cause undesired results.
\\nIf you are using a "-vf" cmd, please put it at the end to avoid issues!
\\nExample:\\n \\nExample:\\n
-look_ahead 1 -look_ahead_depth 100 -extbrc 1 -rdo 1 -mbbrc 1 -b_strategy 1 -adaptive_i 1 -adaptive_b 1 -look_ahead 1 -look_ahead_depth 100 -extbrc 1 -rdo 1 -mbbrc 1 -b_strategy 1 -adaptive_i 1 -adaptive_b 1
\\n Above enables look ahead, extended bitrate control, b-frames, etc.\\n \\n Above enables look ahead, extended bitrate control, b-frames, etc.\\n
@ -664,7 +665,13 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
extraArguments += '-profile:v main10 -pix_fmt p010le '; extraArguments += '-profile:v main10 -pix_fmt p010le ';
response.infoLog += '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n'; 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 } else if (main10 === true) { // Pixel formate method when using HW decode
extraArguments += '-profile:v main10 -vf scale_qsv=format=p010le '; if (inputs.extra_qsv_options.search('-vf scale_qsv') >= 0) {
extraArguments += '-profile:v main10';
// eslint-disable-next-line no-param-reassign
inputs.extra_qsv_options += ':format=p010le'; // Only add on the pixel format to existing scale_qsv cmd
} else {
extraArguments += '-profile:v main10 -vf scale_qsv=format=p010le';
}
response.infoLog += '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n'; response.infoLog += '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n';
} }
@ -696,7 +703,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
break; break;
case 'win32': // Windows - Full device, should fix child_device_type warnings case 'win32': // Windows - Full device, should fix child_device_type warnings
response.preset += `-hwaccel qsv -hwaccel_output_format qsv response.preset += `-hwaccel qsv -hwaccel_output_format qsv
-init_hw_device qsv=qsv:MFX_IMPL_hw `; -init_hw_device qsv:hw,child_device_type=d3d11va `;
break; break;
default: default:
response.preset += '-hwaccel qsv -hwaccel_output_format qsv -init_hw_device qsv:hw_any '; response.preset += '-hwaccel qsv -hwaccel_output_format qsv -init_hw_device qsv:hw_any ';
@ -743,34 +750,86 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
response.preset += 'hevc_qsv'; response.preset += 'hevc_qsv';
break; break;
case 'win32': case 'win32':
response.preset += 'hevc_qsv -load_plugin hevc_hw'; response.preset += 'hevc_qsv';
// Windows needs the additional -load_plugin. Tested working on a Win 10 - i5-10505 // Tested working on a Win 10 - i5-10505
break; break;
default: default:
response.preset += 'hevc_qsv'; // Default to QSV response.preset += 'hevc_qsv'; // Default to QSV
} }
// If HW decode is happening add hwupload to encode // Check if -vf cmd has already been used on user input
if (os.platform() !== 'darwin') { if (high10 !== true) {
if (high10 === false) { // Don't enable for High10 if (inputs.extra_qsv_options.search('-vf scale_qsv') >= 0) {
switch (file.video_codec_name) {
case 'mpeg2':
// eslint-disable-next-line no-param-reassign
inputs.extra_qsv_options += ',hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'h264':
// eslint-disable-next-line no-param-reassign
inputs.extra_qsv_options += ',hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'mjpeg':
// eslint-disable-next-line no-param-reassign
inputs.extra_qsv_options += ',hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'hevc':
// eslint-disable-next-line no-param-reassign
inputs.extra_qsv_options += ',hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'vp9': // Should be supported by 8th Gen +
// eslint-disable-next-line no-param-reassign
inputs.extra_qsv_options += ',hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'av1': // Should be supported by 11th gen +
// eslint-disable-next-line no-param-reassign
inputs.extra_qsv_options += ',hwupload=extra_hw_frames=64,format=qsv ';
break;
default:
}
} else if (extraArguments.search('-vf') === -1) {
// Check if -vf cmd has been used on the other var instead, if not add it & rest of cmd
switch (file.video_codec_name) {
case 'mpeg2':
extraArguments += '-vf hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'h264':
extraArguments += '-vf hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'mjpeg':
extraArguments += '-vf hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'hevc':
extraArguments += '-vf hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'vp9': // Should be supported by 8th Gen +
extraArguments += '-vf hwupload=extra_hw_frames=64,format=qsv ';
break;
case 'av1': // Should be supported by 11th gen +
extraArguments += '-vf hwupload=extra_hw_frames=64,format=qsv ';
break;
default:
}
} else {
// Otherwise add the cmd onto the end
switch (file.video_codec_name) { switch (file.video_codec_name) {
case 'mpeg2': case 'mpeg2':
extraArguments += '-vf "hwupload=extra_hw_frames=64,format=qsv" '; extraArguments += ',hwupload=extra_hw_frames=64,format=qsv ';
break; break;
case 'h264': case 'h264':
extraArguments += '-vf "hwupload=extra_hw_frames=64,format=qsv" '; extraArguments += ',hwupload=extra_hw_frames=64,format=qsv ';
break; break;
case 'mjpeg': case 'mjpeg':
extraArguments += '-vf "hwupload=extra_hw_frames=64,format=qsv" '; extraArguments += ',hwupload=extra_hw_frames=64,format=qsv ';
break; break;
case 'hevc': case 'hevc':
extraArguments += '-vf "hwupload=extra_hw_frames=64,format=qsv" '; extraArguments += ',hwupload=extra_hw_frames=64,format=qsv ';
break; break;
case 'vp9': // Should be supported by 8th Gen + case 'vp9': // Should be supported by 8th Gen +
extraArguments += '-vf "hwupload=extra_hw_frames=64,format=qsv" '; extraArguments += ',hwupload=extra_hw_frames=64,format=qsv ';
break; break;
case 'av1': // Should be supported by 11th gen + case 'av1': // Should be supported by 11th gen +
extraArguments += '-vf "hwupload=extra_hw_frames=64,format=qsv" '; extraArguments += ',hwupload=extra_hw_frames=64,format=qsv ';
break; break;
default: default:
} }

@ -31,7 +31,7 @@ const tests = [
win32: { win32: {
processFile: true, processFile: true,
preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n' preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n'
+ ' -init_hw_device qsv=qsv:MFX_IMPL_hw -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 slow -c:a copy -c:s copy -max_muxing_queue_size 9999 -f matroska -vf "hwupload=extra_hw_frames=64,format=qsv" ', + ' -init_hw_device qsv:hw,child_device_type=d3d11va -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -b:v 603k -minrate 452k -maxrate 754k -bufsize 1206k -preset slow -c:a copy -c:s copy -max_muxing_queue_size 9999 -f matroska ',
handBrakeMode: false, handBrakeMode: false,
FFmpegMode: true, FFmpegMode: true,
reQueueAfter: true, reQueueAfter: true,
@ -96,7 +96,7 @@ const tests = [
win32: { win32: {
processFile: true, processFile: true,
preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n' preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n'
+ ' -init_hw_device qsv=qsv:MFX_IMPL_hw -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 -f mp4 -profile:v main10 -vf scale_qsv=format=p010le -vf "hwupload=extra_hw_frames=64,format=qsv" ', + ' -init_hw_device qsv:hw,child_device_type=d3d11va -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 -f mp4 -profile:v main10 -vf scale_qsv=format=p010le',
handBrakeMode: false, handBrakeMode: false,
FFmpegMode: true, FFmpegMode: true,
reQueueAfter: true, reQueueAfter: true,
@ -166,7 +166,7 @@ const tests = [
}, },
win32: { win32: {
processFile: true, processFile: true,
preset: '-fflags +genpts <io> -map 0 -c:v hevc_qsv -load_plugin hevc_hw -b:v 3227k -minrate 2420k -maxrate 4034k -bufsize 6454k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -f matroska -profile:v main10 -pix_fmt p010le ', preset: '-fflags +genpts <io> -map 0 -c:v hevc_qsv -b:v 3227k -minrate 2420k -maxrate 4034k -bufsize 6454k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -f matroska -profile:v main10 -pix_fmt p010le ',
handBrakeMode: false, handBrakeMode: false,
FFmpegMode: true, FFmpegMode: true,
reQueueAfter: true, reQueueAfter: true,
@ -243,7 +243,7 @@ const tests = [
win32: { win32: {
processFile: true, processFile: true,
preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n' preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n'
+ ' -init_hw_device qsv=qsv:MFX_IMPL_hw -c:v hevc_qsv<io> -map 0 -c:v hevc_qsv -load_plugin hevc_hw -b:v 6000k -minrate 4500k -maxrate 7500k -bufsize 12000k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -f matroska -profile:v main10 -vf scale_qsv=format=p010le -vf "hwupload=extra_hw_frames=64,format=qsv" ', + ' -init_hw_device qsv:hw,child_device_type=d3d11va -c:v hevc_qsv<io> -map 0 -c:v hevc_qsv -b:v 6000k -minrate 4500k -maxrate 7500k -bufsize 12000k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -f matroska -profile:v main10 -vf scale_qsv=format=p010le ',
handBrakeMode: false, handBrakeMode: false,
FFmpegMode: true, FFmpegMode: true,
reQueueAfter: true, reQueueAfter: true,
@ -352,7 +352,7 @@ const tests = [
win32: { win32: {
processFile: true, processFile: true,
preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n' preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n'
+ ' -init_hw_device qsv=qsv:MFX_IMPL_hw -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -load_plugin hevc_hw -b:v 3227k -minrate 2420k -maxrate 4034k -bufsize 6454k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -map -0:3 -map -0:4 -map -0:5 -map -0:6 -f mp4 -vf "hwupload=extra_hw_frames=64,format=qsv" ', + ' -init_hw_device qsv:hw,child_device_type=d3d11va -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -b:v 3227k -minrate 2420k -maxrate 4034k -bufsize 6454k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -map -0:3 -map -0:4 -map -0:5 -map -0:6 -f mp4 ',
handBrakeMode: false, handBrakeMode: false,
FFmpegMode: true, FFmpegMode: true,
reQueueAfter: true, reQueueAfter: true,
@ -420,7 +420,7 @@ const tests = [
win32: { win32: {
processFile: true, processFile: true,
preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n' preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n'
+ ' -init_hw_device qsv=qsv:MFX_IMPL_hw -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -load_plugin hevc_hw -b:v 3227k -minrate 2420k -maxrate 4034k -bufsize 6454k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -map -0:d -map -0:3 -map -0:4 -map -0:5 -f matroska -vf "hwupload=extra_hw_frames=64,format=qsv" ', + ' -init_hw_device qsv:hw,child_device_type=d3d11va -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -b:v 3227k -minrate 2420k -maxrate 4034k -bufsize 6454k -preset fast -c:a copy -c:s copy -max_muxing_queue_size 9999 -map -0:d -map -0:3 -map -0:4 -map -0:5 -f matroska ',
handBrakeMode: false, handBrakeMode: false,
FFmpegMode: true, FFmpegMode: true,
reQueueAfter: true, reQueueAfter: true,
@ -450,6 +450,73 @@ const tests = [
}, },
}, },
}, },
// Test 7
{
input: {
file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')),
librarySettings: {},
inputs: {
container: 'mkv',
encoder_speedpreset: 'fast',
extra_qsv_options: '-look_ahead 1 -look_ahead_depth 100 -extbrc 1 -rdo 1 -mbbrc 1 -b_strategy 1 -adaptive_i 1 -adaptive_b 1 -vf scale_qsv=1280:-1',
enable_10bit: 'true',
},
otherArguments: {},
},
output: {
linux: {
processFile: true,
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 -look_ahead 1 -look_ahead_depth 100 -extbrc 1 -rdo 1 -mbbrc 1 -b_strategy 1 -adaptive_i 1 -adaptive_b 1 -vf scale_qsv=1280:-1:format=p010le -c:a copy -c:s copy -max_muxing_queue_size 9999 -f matroska -profile:v main10',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ It looks like the current video bitrate is 1206kbps. \n'
+ '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n'
+ 'Container for output selected as mkv. \n'
+ 'Encode variable bitrate settings: \n'
+ 'Target = 603k \n'
+ 'Minimum = 452k \n'
+ 'Maximum = 754k \n'
+ 'File Transcoding... \n',
container: '.mkv',
},
win32: {
processFile: true,
preset: '-fflags +genpts -hwaccel qsv -hwaccel_output_format qsv \n'
+ ' -init_hw_device qsv:hw,child_device_type=d3d11va -c:v h264_qsv<io> -map 0 -c:v hevc_qsv -b:v 603k -minrate 452k -maxrate 754k -bufsize 1206k -preset fast -look_ahead 1 -look_ahead_depth 100 -extbrc 1 -rdo 1 -mbbrc 1 -b_strategy 1 -adaptive_i 1 -adaptive_b 1 -vf scale_qsv=1280:-1:format=p010le -c:a copy -c:s copy -max_muxing_queue_size 9999 -f matroska -profile:v main10',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ It looks like the current video bitrate is 1206kbps. \n'
+ '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n'
+ 'Container for output selected as mkv. \n'
+ 'Encode variable bitrate settings: \n'
+ 'Target = 603k \n'
+ 'Minimum = 452k \n'
+ 'Maximum = 754k \n'
+ 'File Transcoding... \n',
container: '.mkv',
},
darwin: {
processFile: true,
preset: '-fflags +genpts -hwaccel videotoolbox<io> -map 0 -c:v hevc_videotoolbox -b:v 603k -minrate 452k -maxrate 754k -bufsize 1206k -preset slow -c:a copy -c:s copy -max_muxing_queue_size 9999 -f matroska ',
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: true,
infoLog: '☑ It looks like the current video bitrate is 1206kbps. \n'
+ '10 bit encode enabled. Setting Main10 Profile & 10 bit pixel format \n'
+ 'Container for output selected as mkv. \n'
+ 'Encode variable bitrate settings: \n'
+ 'Target = 603k \n'
+ 'Minimum = 452k \n'
+ 'Maximum = 754k \n'
+ '==ALERT== OS detected as MAC - This will use VIDEOTOOLBOX to encode which is NOT QSV\n'
+ 'cmds set in extra_qsv_options will be IGNORED!\n'
+ 'File Transcoding... \n',
container: '.mkv',
},
},
},
]; ];
void run(tests); void run(tests);

Loading…
Cancel
Save