mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-18 19:56:24 -07:00
QSV Mpeg4 fix
- Fall back to software transcode when video is mpeg4. - Check for stream tags before trying to access them.
This commit is contained in:
parent
4308c596ea
commit
a21852d233
1 changed files with 39 additions and 35 deletions
|
|
@ -184,7 +184,6 @@ function buildAudioConfiguration(_inputs, file, logger) {
|
|||
var configuration = new Configurator(["-c:a copy"]);
|
||||
var hasNonAc3MultiChannelAudio = false;
|
||||
var hasMultiChannelAudio = false;
|
||||
|
||||
loopOverStreamsOfType(file, "audio", function (stream, id) {
|
||||
hasMultiChannelAudio = stream.channels >= 6;
|
||||
if (stream.codec_name !== "ac3" && stream.channels >= 6) {
|
||||
|
|
@ -192,7 +191,7 @@ function buildAudioConfiguration(_inputs, file, logger) {
|
|||
hasNonAc3MultiChannelAudio = true;
|
||||
}
|
||||
|
||||
if ("title" in stream.tags) {
|
||||
if ("tags" in stream && "title" in stream.tags) {
|
||||
if (
|
||||
stream.tags.title.toLowerCase().includes("commentary") ||
|
||||
stream.tags.title.toLowerCase().includes("description") ||
|
||||
|
|
@ -241,6 +240,7 @@ function buildSubtitleConfiguration(inputs, file, logger) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ("tags" in stream) {
|
||||
// Remove unwated languages
|
||||
if ("language" in stream.tags) {
|
||||
if (languages.indexOf(stream.tags.language.toLowerCase()) === -1) {
|
||||
|
|
@ -264,6 +264,7 @@ function buildSubtitleConfiguration(inputs, file, logger) {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!configuration.shouldProcess) {
|
||||
|
|
@ -286,7 +287,6 @@ function buildVideoConfiguration(inputs, file, logger) {
|
|||
return;
|
||||
}
|
||||
|
||||
// If MKV file with hevc codec, don't need to do anything
|
||||
if (stream.codec_name === "hevc" && file.container === "mkv") {
|
||||
logger.AddSuccess("File is in HEVC codec and in MKV");
|
||||
return;
|
||||
|
|
@ -301,8 +301,8 @@ function buildVideoConfiguration(inputs, file, logger) {
|
|||
// Check if should Transcode.
|
||||
if (stream.codec_name !== "hevc") {
|
||||
var bitrate = calculateBitrate(file);
|
||||
if (inputs.minimum_target_bitrate !== "") {
|
||||
if (
|
||||
inputs.minimum_target_bitrate !== "" &&
|
||||
bitrate.target < inputs.minimum_target_bitrate
|
||||
) {
|
||||
logger.AddError(
|
||||
|
|
@ -310,14 +310,13 @@ function buildVideoConfiguration(inputs, file, logger) {
|
|||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var bitrateSettings = `-b:v ${bitrate.target}k -minrate ${bitrate.min}k -maxrate ${bitrate.max}k -bufsize ${bitrate.original}k`;
|
||||
|
||||
/**
|
||||
* Intel Quick Sync configuration
|
||||
*/
|
||||
if (inputs.qsv === "true") {
|
||||
if (inputs.qsv === "true" && stream.codec_name !== "mpeg4") {
|
||||
configuration.AddInputSetting(
|
||||
"-hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi"
|
||||
);
|
||||
|
|
@ -359,10 +358,13 @@ function buildVideoConfiguration(inputs, file, logger) {
|
|||
logger.AddError("Transcoding to HEVC using NVidia NVENC");
|
||||
}
|
||||
|
||||
if (inputs.qsv !== "true" && inputs.nvenc !== "true") {
|
||||
if (
|
||||
(inputs.qsv !== "true" && inputs.nvenc !== "true") ||
|
||||
stream.codec_name === "mpeg4"
|
||||
) {
|
||||
configuration.RemoveOutputSetting("-c:v copy");
|
||||
configuration.AddOutputSetting(`-c:v libx265 ${bitrateSettings}`);
|
||||
logger.AddError("Transcoding to HEVC");
|
||||
logger.AddError("Transcoding to HEVC (software)");
|
||||
}
|
||||
|
||||
logger.Add(
|
||||
|
|
@ -403,7 +405,9 @@ function plugin(file, _librarySettings, inputs) {
|
|||
|
||||
response.preset = `${videoSettings.GetInputSettings()},${videoSettings.GetOutputSettings()} ${audioSettings.GetOutputSettings()} ${subtitleSettings.GetOutputSettings()} -max_muxing_queue_size 4096`;
|
||||
response.processFile =
|
||||
audioSettings.shouldProcess || videoSettings.shouldProcess || subtitleSettings.shouldProcess;
|
||||
audioSettings.shouldProcess ||
|
||||
videoSettings.shouldProcess ||
|
||||
subtitleSettings.shouldProcess;
|
||||
|
||||
if (!response.processFile) {
|
||||
logger.AddSuccess("No need to process file");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue