mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-02-06 01:59:09 -06:00
set WarningsAsErrors = true
This commit is contained in:
@@ -158,7 +158,7 @@ public class CreateAudioBook: AudioNode
|
||||
|
||||
string outputFile = FileHelper.Combine(args.TempPath, Guid.NewGuid() + ".m4b");
|
||||
|
||||
string artwork = null; //FindArtwork(dir);
|
||||
string? artwork = null; //FindArtwork(dir);
|
||||
|
||||
List<string> execArgs = new() {
|
||||
"-f",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<Product>Comic</Product>
|
||||
<PackageProjectUrl>https://fileflows.com/</PackageProjectUrl>
|
||||
<Description>Flow elements for processing comic books (cbr, cbz, pdf etc)</Description>
|
||||
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="ComicNodes.en.json" />
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ComicConverter: Node
|
||||
[Select(nameof(FormatOptions), 1)]
|
||||
public string Format { get; set; } = string.Empty;
|
||||
|
||||
private static List<ListOption> _FormatOptions;
|
||||
private static List<ListOption>? _FormatOptions;
|
||||
/// <summary>
|
||||
/// Gets the format options
|
||||
/// </summary>
|
||||
@@ -70,7 +70,7 @@ public class ComicConverter: Node
|
||||
[Select(nameof(CodecOptions), 4)]
|
||||
public string Codec { get; set; } = string.Empty;
|
||||
|
||||
private static List<ListOption> _CodecOptions;
|
||||
private static List<ListOption>? _CodecOptions;
|
||||
/// <summary>
|
||||
/// Gets the format options
|
||||
/// </summary>
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ComicExtractor : Node
|
||||
/// </summary>
|
||||
[Required]
|
||||
[Folder(1)]
|
||||
public string DestinationPath { get; set; }
|
||||
public string DestinationPath { get; set; } = string.Empty;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Execute(NodeParameters args)
|
||||
|
||||
@@ -66,7 +66,7 @@ public class CreateComicInfo : Node
|
||||
}
|
||||
args.Logger?.ILog("Got ComicInfo from filename");
|
||||
|
||||
var newMetadata = new Dictionary<string, object>
|
||||
var newMetadata = new Dictionary<string, object?>
|
||||
{
|
||||
{ nameof(info.Value.Title), info.Value.Title },
|
||||
{ nameof(info.Value.Series), info.Value.Series },
|
||||
|
||||
@@ -22,7 +22,7 @@ internal class PdfHelper
|
||||
|
||||
var file = Path.Combine(destinationDirectory,
|
||||
filePrefix + "-" + i.ToString(new string('0', pageCount.ToString().Length)));
|
||||
var result = args.ImageHelper.SaveImage(rawBytes, file);
|
||||
var result = args!.ImageHelper.SaveImage(rawBytes, file);
|
||||
if (result.Failed(out string error))
|
||||
{
|
||||
args.Logger?.WLog("Failed to save image: " + error);
|
||||
@@ -52,8 +52,8 @@ internal class PdfHelper
|
||||
/// <param name="halfProgress">if the NodePArameter.PartPercentageUpdate should start at 50%</param>
|
||||
internal static void Create(NodeParameters args, string directory, string output, bool halfProgress = true)
|
||||
{
|
||||
if (args?.PartPercentageUpdate != null)
|
||||
args?.PartPercentageUpdate(halfProgress ? 50 : 0);
|
||||
if (args.PartPercentageUpdate != null)
|
||||
args.PartPercentageUpdate(halfProgress ? 50 : 0);
|
||||
var rgxImages = new Regex(@"\.(jpeg|jpg|jpe|png|webp)$");
|
||||
var files = Directory.GetFiles(directory).Where(x => rgxImages.IsMatch(x)).ToArray();
|
||||
|
||||
@@ -64,11 +64,11 @@ internal class PdfHelper
|
||||
if (file.ToLowerInvariant().EndsWith(".png") || file.ToLowerInvariant().EndsWith(".webp"))
|
||||
{
|
||||
string jpegImage = Path.ChangeExtension(file, "jpg");
|
||||
args.ImageHelper.ConvertToJpeg(file, jpegImage, null);
|
||||
args!.ImageHelper.ConvertToJpeg(file, jpegImage, null);
|
||||
file = jpegImage;
|
||||
}
|
||||
|
||||
(int width, int height) = args.ImageHelper.GetDimensions(file).Value;
|
||||
(int width, int height) = args!.ImageHelper.GetDimensions(file).Value;
|
||||
|
||||
var jpeg = new JpegImage
|
||||
{
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace FileFlows.ComicNodes.Helpers;
|
||||
|
||||
internal class UnrarCommandLine
|
||||
{
|
||||
/// <summary>
|
||||
/// Uncompresses a folder
|
||||
/// </summary>
|
||||
/// <param name="args">the node paratemers</param>
|
||||
/// <param name="workingFile">the file to extract</param>
|
||||
/// <param name="destinationPath">the location to extract to</param>
|
||||
/// <param name="halfProgress">if the NodeParameter.PartPercentageUpdate should end at 50%</param>
|
||||
internal static void Extract(NodeParameters args, string workingFile, string destinationPath, bool halfProgress = true)
|
||||
{
|
||||
if (args?.PartPercentageUpdate != null)
|
||||
args?.PartPercentageUpdate(halfProgress ? 50 : 0);
|
||||
|
||||
var process = new Process();
|
||||
string unrar = args.GetToolPath("unrar")?.EmptyAsNull() ?? "unrar";
|
||||
process.StartInfo.FileName = unrar;
|
||||
process.StartInfo.ArgumentList.Add("x");
|
||||
process.StartInfo.ArgumentList.Add("-o+");
|
||||
process.StartInfo.ArgumentList.Add(workingFile);
|
||||
process.StartInfo.ArgumentList.Add(destinationPath);
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.RedirectStandardError = true;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
process.Start();
|
||||
string output = process.StandardError.ReadToEnd();
|
||||
string error = process.StandardError.ReadToEnd();
|
||||
process.WaitForExit();
|
||||
|
||||
args.Logger?.ILog("Unrar output:\n" + output);
|
||||
if (string.IsNullOrWhiteSpace(error) == false)
|
||||
args.Logger?.ELog("Unrar error:\n" + error);
|
||||
|
||||
if (process.ExitCode != 0)
|
||||
throw new Exception(error?.EmptyAsNull() ?? "Failed to extract rar file");
|
||||
|
||||
PageNameHelper.FixPageNames(destinationPath);
|
||||
|
||||
if (args?.PartPercentageUpdate != null)
|
||||
args?.PartPercentageUpdate(halfProgress ? 50 : 100);
|
||||
}
|
||||
|
||||
internal static int GetImageCount(NodeParameters args, string workingFile)
|
||||
{
|
||||
var rgxImages = new Regex(@"\.(jpeg|jpg|jpe|png|bmp|tiff|webp|gif)$", RegexOptions.IgnoreCase);
|
||||
|
||||
var process = new Process();
|
||||
string unrar = args.GetToolPath("unrar")?.EmptyAsNull() ?? "unrar";
|
||||
process.StartInfo.FileName = unrar;
|
||||
process.StartInfo.ArgumentList.Add("list");
|
||||
process.StartInfo.ArgumentList.Add(workingFile);
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.RedirectStandardError = true;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
process.Start();
|
||||
string output = process.StandardError.ReadToEnd();
|
||||
string error = process.StandardError.ReadToEnd();
|
||||
process.WaitForExit();
|
||||
|
||||
if (process.ExitCode != 0)
|
||||
throw new Exception(error?.EmptyAsNull() ?? "Failed to open rar file");
|
||||
|
||||
var lines = output.Split('\n', StringSplitOptions.RemoveEmptyEntries);
|
||||
return lines.Count(x => rgxImages.IsMatch(x.Trim()));
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class ComicInfoTests : TestBase
|
||||
Assert.AreEqual("Batman (1939)", info.Series);
|
||||
Assert.AreEqual("1939", info.Volume);
|
||||
Assert.AreEqual("Batman vs. Joker", info.Title);
|
||||
Assert.AreEqual(3, info.Tags.Length);
|
||||
Assert.AreEqual(3, info.Tags!.Length);
|
||||
Assert.AreEqual("old", info.Tags[0]);
|
||||
Assert.AreEqual("great", info.Tags[1]);
|
||||
Assert.AreEqual("amazing", info.Tags[2]);
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ComicTests : TestBase
|
||||
public void Comic_Pdf_To_Cbz()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\fp1.pdf", logger, false, string.Empty, null);
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\fp1.pdf", logger, false, string.Empty, null!);
|
||||
args.TempPath = @"D:\comics\temp";
|
||||
|
||||
var node = new ComicConverter();
|
||||
@@ -27,7 +27,7 @@ public class ComicTests : TestBase
|
||||
public void Comic_Cbz_To_Pdf()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\mb.cbz", logger, false, string.Empty, null);
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\mb.cbz", logger, false, string.Empty, null!);
|
||||
args.TempPath = @"D:\comics\temp";
|
||||
|
||||
var node = new ComicConverter();
|
||||
@@ -42,7 +42,7 @@ public class ComicTests : TestBase
|
||||
public void Comic_Cb7_To_Cbz()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\cb7.cb7", logger, false, string.Empty, null);
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\cb7.cb7", logger, false, string.Empty, null!);
|
||||
args.TempPath = @"D:\comics\temp";
|
||||
|
||||
var node = new ComicConverter();
|
||||
@@ -57,7 +57,7 @@ public class ComicTests : TestBase
|
||||
public void Comic_Cbr_To_Cbz()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\bm001.cbr", logger, false, string.Empty, null);
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\bm001.cbr", logger, false, string.Empty, null!);
|
||||
args.TempPath = @"D:\comics\temp";
|
||||
|
||||
var node = new ComicConverter();
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ExtractTests
|
||||
public void Extract_Pdf()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new NodeParameters(@"/home/john/Comics/unprocessed/Ghosts Book 1 Excerpt.pdf", logger, false, string.Empty, null);
|
||||
var args = new NodeParameters(@"/home/john/Comics/unprocessed/Ghosts Book 1 Excerpt.pdf", logger, false, string.Empty, null!);
|
||||
|
||||
var node = new ComicExtractor();
|
||||
node.DestinationPath = @"/home/john/Comics/extracted";
|
||||
@@ -29,7 +29,7 @@ public class ExtractTests
|
||||
public void Extract_Cbr()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\bm001.cbr", logger, false, string.Empty, null);
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\bm001.cbr", logger, false, string.Empty, null!);
|
||||
|
||||
var node = new ComicExtractor();
|
||||
node.DestinationPath = @"D:\comics\converted\cbr";
|
||||
@@ -46,7 +46,7 @@ public class ExtractTests
|
||||
public void Extract_Cbz()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\mb.cbz", logger, false, string.Empty, null);
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\mb.cbz", logger, false, string.Empty, null!);
|
||||
|
||||
var node = new ComicExtractor();
|
||||
node.DestinationPath = @"D:\comics\converted\cbz";
|
||||
@@ -63,7 +63,7 @@ public class ExtractTests
|
||||
public void Extract_Cb7()
|
||||
{
|
||||
var logger = new TestLogger();
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\cb7.cb7", logger, false, string.Empty, null);
|
||||
var args = new NodeParameters(@"D:\comics\testfiles\cb7.cb7", logger, false, string.Empty, null!);
|
||||
|
||||
var node = new ComicExtractor();
|
||||
node.DestinationPath = @"D:\comics\converted\cb7";
|
||||
|
||||
@@ -24,11 +24,13 @@ internal class TestLogger : ILogger
|
||||
{
|
||||
if (args == null || args.Length == 0)
|
||||
return;
|
||||
#pragma warning disable IL2026
|
||||
string message = type + " -> " +
|
||||
string.Join(", ", args.Select(x =>
|
||||
x == null ? "null" :
|
||||
x.GetType().IsPrimitive || x is string ? x.ToString() :
|
||||
System.Text.Json.JsonSerializer.Serialize(x)));
|
||||
#pragma warning restore IL2026
|
||||
Messages.Add(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class LocalFileService : IFileService
|
||||
/// <summary>
|
||||
/// Gets or sets the allowed paths the file service can access
|
||||
/// </summary>
|
||||
public string[] AllowedPaths { get; init; }
|
||||
public string[]? AllowedPaths { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a function for replacing variables in a string.
|
||||
@@ -25,7 +25,7 @@ public class LocalFileService : IFileService
|
||||
/// The function takes a string input, a boolean indicating whether to strip missing variables,
|
||||
/// and a boolean indicating whether to clean special characters.
|
||||
/// </remarks>
|
||||
public ReplaceVariablesDelegate ReplaceVariables { get; set; }
|
||||
public ReplaceVariablesDelegate? ReplaceVariables { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the permissions to use for files
|
||||
@@ -35,7 +35,7 @@ public class LocalFileService : IFileService
|
||||
/// <summary>
|
||||
/// Gets or sets the owner:group to use for files
|
||||
/// </summary>
|
||||
public string OwnerGroup { get; set; }
|
||||
public string? OwnerGroup { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the logger used for logging
|
||||
@@ -168,7 +168,7 @@ public class LocalFileService : IFileService
|
||||
Name = fileInfo.Name,
|
||||
FullName = fileInfo.FullName,
|
||||
Length = fileInfo.Length,
|
||||
Directory = fileInfo.DirectoryName
|
||||
Directory = fileInfo.DirectoryName!
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -257,7 +257,7 @@ public class LocalFileService : IFileService
|
||||
if (fileInfo.Exists == false)
|
||||
return Result<bool>.Fail("File does not exist");
|
||||
var destDir = new FileInfo(destination).Directory;
|
||||
if (destDir.Exists == false)
|
||||
if (destDir!.Exists == false)
|
||||
{
|
||||
destDir.Create();
|
||||
SetPermissions(destDir.FullName);
|
||||
@@ -286,7 +286,7 @@ public class LocalFileService : IFileService
|
||||
return Result<bool>.Fail("File does not exist");
|
||||
|
||||
var destDir = new FileInfo(destination).Directory;
|
||||
if (destDir.Exists == false)
|
||||
if (destDir!.Exists == false)
|
||||
{
|
||||
destDir.Create();
|
||||
SetPermissions(destDir.FullName);
|
||||
@@ -434,7 +434,7 @@ public class LocalFileService : IFileService
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetPermissions(string path, int? permissions = null, Action<string> logMethod = null)
|
||||
public void SetPermissions(string path, int? permissions = null, Action<string>? logMethod = null)
|
||||
{
|
||||
logMethod ??= (string message) => Logger?.ILog(message);
|
||||
|
||||
@@ -456,26 +456,9 @@ public class LocalFileService : IFileService
|
||||
|
||||
FileHelper.SetPermissions(logger, path, file: isFile, permissions: permissions);
|
||||
|
||||
FileHelper.ChangeOwner(logger, path, file: isFile, ownerGroup: OwnerGroup);
|
||||
FileHelper.ChangeOwner(logger, path, file: isFile, ownerGroup: OwnerGroup!);
|
||||
|
||||
logMethod(logger.ToString());
|
||||
|
||||
return;
|
||||
|
||||
|
||||
if (OperatingSystem.IsLinux())
|
||||
{
|
||||
var filePermissions = FileHelper.ConvertLinuxPermissionsToUnixFileMode(permissions.Value);
|
||||
if (filePermissions == UnixFileMode.None)
|
||||
{
|
||||
logMethod("SetPermissions: Invalid file permissions: " + permissions.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
File.SetUnixFileMode(path, filePermissions);
|
||||
logMethod($"SetPermissions: Permission [{filePermissions}] set on file: " + path);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -16,14 +16,14 @@ public abstract class TestBase
|
||||
/// <summary>
|
||||
/// The test context instance
|
||||
/// </summary>
|
||||
private TestContext testContextInstance;
|
||||
private TestContext? testContextInstance;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the test context
|
||||
/// </summary>
|
||||
public TestContext TestContext
|
||||
{
|
||||
get => testContextInstance;
|
||||
get => testContextInstance!;
|
||||
set => testContextInstance = value;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -96,7 +96,7 @@ public class FFMpegEncoder
|
||||
var result = new ProcessResult();
|
||||
|
||||
var hwDecoderIndex = arguments.FindIndex(x => x == "-hwaccel");
|
||||
string decoder = null;
|
||||
string? decoder = null;
|
||||
if (hwDecoderIndex >= 0 && hwDecoderIndex < arguments.Count - 2)
|
||||
{
|
||||
var decoder2 = arguments[hwDecoderIndex + 1].ToLowerInvariant();
|
||||
@@ -131,7 +131,7 @@ public class FFMpegEncoder
|
||||
OnStatChange?.Invoke("Decoder", decoder, recordStatistic: true);
|
||||
}
|
||||
|
||||
string encoder = null;
|
||||
string? encoder = null;
|
||||
if (arguments.Any(x =>
|
||||
x.ToLowerInvariant().Contains("hevc_qsv") || x.ToLowerInvariant().Contains("h264_qsv") ||
|
||||
x.ToLowerInvariant().Contains("av1_qsv")))
|
||||
|
||||
@@ -250,7 +250,7 @@ public class FfmpegBuilderAudioConverter : FfmpegBuilderNode
|
||||
}
|
||||
else
|
||||
{
|
||||
string testValue = Field switch
|
||||
string? testValue = Field switch
|
||||
{
|
||||
FIELD_LANGUAGE => track.Language?.EmptyAsNull() ?? track.Stream?.Language ?? string.Empty,
|
||||
FIELD_TITLE => track.Title?.EmptyAsNull() ?? track.Stream?.Title ?? string.Empty,
|
||||
|
||||
@@ -24,7 +24,7 @@ public class FfmpegBuilderAudioNormalization : FfmpegBuilderNode
|
||||
|
||||
internal const string LOUDNORM_TARGET = "I=-24:LRA=7:TP=-2.0";
|
||||
|
||||
[RequiresUnreferencedCode("")]
|
||||
/// <inheritdoc />
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
if (Model.AudioStreams?.Any() != true)
|
||||
@@ -60,8 +60,8 @@ public class FfmpegBuilderAudioNormalization : FfmpegBuilderNode
|
||||
|
||||
if (TwoPass)
|
||||
{
|
||||
if (normalizedTracks.ContainsKey(audio.TypeIndex))
|
||||
item.stream.Filter.Add(normalizedTracks[audio.TypeIndex]);
|
||||
if (normalizedTracks.TryGetValue(audio.TypeIndex, out var track))
|
||||
item.stream.Filter.Add(track);
|
||||
else
|
||||
{
|
||||
string twoPass = DoTwoPass(this, args, FFMPEG, audio.TypeIndex, localFile);
|
||||
@@ -78,10 +78,7 @@ public class FfmpegBuilderAudioNormalization : FfmpegBuilderNode
|
||||
|
||||
return normalizing ? 1 : 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.Deserialize<FileFlows.VideoNodes.AudioNormalization.LoudNormStats>(string, System.Text.Json.JsonSerializerOptions?)")]
|
||||
|
||||
public static string DoTwoPass(EncodingNode node, NodeParameters args, string ffmpegExe, int audioIndex, string localFile)
|
||||
{
|
||||
//-af loudnorm=I=-24:LRA=7:TP=-2.0"
|
||||
@@ -108,9 +105,9 @@ public class FfmpegBuilderAudioNormalization : FfmpegBuilderNode
|
||||
json = json.Substring(0, json.IndexOf("}", StringComparison.Ordinal) + 1);
|
||||
if (string.IsNullOrEmpty(json))
|
||||
throw new Exception("Failed to parse TwoPass json");
|
||||
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
|
||||
LoudNormStats stats = JsonSerializer.Deserialize<LoudNormStats>(json);
|
||||
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
|
||||
#pragma warning disable IL2026
|
||||
LoudNormStats? stats = JsonSerializer.Deserialize<LoudNormStats>(json);
|
||||
#pragma warning restore IL2026
|
||||
|
||||
if (stats.input_i == "-inf" || stats.input_lra == "-inf" || stats.input_tp == "-inf" || stats.input_thresh == "-inf" || stats.target_offset == "-inf")
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FfmpegBuilderAudioSetLanguage : FfmpegBuilderNode
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
bool changes = false;
|
||||
string language = args.ReplaceVariables(Language, stripMissing: true)?.ToLowerInvariant();
|
||||
string? language = args.ReplaceVariables(Language, stripMissing: true)?.ToLowerInvariant();
|
||||
if (string.IsNullOrWhiteSpace(language))
|
||||
{
|
||||
args.Logger?.WLog("No language set");
|
||||
@@ -63,9 +63,9 @@ public class FfmpegBuilderAudioSetLanguage : FfmpegBuilderNode
|
||||
|
||||
if (language.ToLowerInvariant().Contains("orig"))
|
||||
{
|
||||
if (Variables.TryGetValue("OriginalLanguage", out object oLang) == false || string.IsNullOrEmpty(oLang as string))
|
||||
if (Variables.TryGetValue("OriginalLanguage", out object? oLang) == false || string.IsNullOrEmpty(oLang as string))
|
||||
{
|
||||
args.Logger?.ILog("OriginalLanguage not found in varaibles.");
|
||||
args.Logger?.ILog("OriginalLanguage not found in variables.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ public class FfmpegBuilderDefaultOriginalLanguage: FfmpegBuilderNode
|
||||
/// <returns>the flow output to call next</returns>
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
string originalLanguage;
|
||||
if (args.Variables.TryGetValue("OriginalLanguage", out object oValue) == false ||
|
||||
string? originalLanguage;
|
||||
if (args.Variables.TryGetValue("OriginalLanguage", out object? oValue) == false ||
|
||||
string.IsNullOrWhiteSpace(originalLanguage = oValue as string))
|
||||
{
|
||||
args.Logger?.ILog("OriginalLanguage variable was not set.");
|
||||
|
||||
@@ -213,7 +213,7 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode
|
||||
{
|
||||
args.Logger?.ILog("HW_OFF detected");
|
||||
}
|
||||
else if (Variables.TryGetValue("HW_OFF", out object oHwOff) &&
|
||||
else if (Variables.TryGetValue("HW_OFF", out object? oHwOff) &&
|
||||
(oHwOff as bool? == true || oHwOff?.ToString() == "1")
|
||||
)
|
||||
{
|
||||
@@ -241,7 +241,7 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode
|
||||
|
||||
args.Logger?.ILog("Pixel Format: " + (video?.Stream?.PixelFormat?.EmptyAsNull() ?? "Unknown"));
|
||||
bool targetIs10Bit = string.Join(" ", ffArgs).Contains("p010le");
|
||||
string pxtFormat = video?.Stream?.PixelFormat;
|
||||
string? pxtFormat = video?.Stream?.PixelFormat;
|
||||
if (targetIs10Bit && video?.Stream?.Is10Bit == true)
|
||||
{
|
||||
args.Logger?.ILog(
|
||||
@@ -569,7 +569,7 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode
|
||||
noDxva2 ? null : new [] { "-hwaccel", "dxva2" },
|
||||
noD3d11va ? null : new [] { "-hwaccel", "d3d11va" },
|
||||
noOpencl ? null : new [] { "-hwaccel", "opencl" },
|
||||
};
|
||||
}.Where(x => x != null).Select(x => x!).ToArray();
|
||||
}
|
||||
|
||||
private static string[][] Decoders_hevc(NodeParameters args)
|
||||
@@ -610,7 +610,7 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode
|
||||
noDxva2 ? null : new [] { "-hwaccel", "dxva2" },
|
||||
noD3d11va ? null : new [] { "-hwaccel", "d3d11va" },
|
||||
noOpencl ? null : new [] { "-hwaccel", "opencl" },
|
||||
};
|
||||
}.Where(x => x != null).Select(x => x!).ToArray();
|
||||
}
|
||||
|
||||
private static string[][] Decoders_Default(NodeParameters args)
|
||||
@@ -653,6 +653,6 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode
|
||||
noDxva2 ? null : new [] { "-hwaccel", "dxva2" },
|
||||
noD3d11va ? null : new [] { "-hwaccel", "d3d11va" },
|
||||
noOpencl ? null : new [] { "-hwaccel", "opencl" },
|
||||
};
|
||||
}.Where(x => x != null).Select(x => x!).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ public class FfmpegBuilderKeepOriginalLanguage: FfmpegBuilderNode
|
||||
/// <returns>the flow output to call next</returns>
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
string originalLanguage;
|
||||
if (args.Variables.TryGetValue("OriginalLanguage", out object oValue) == false ||
|
||||
string? originalLanguage;
|
||||
if (args.Variables.TryGetValue("OriginalLanguage", out object? oValue) == false ||
|
||||
string.IsNullOrWhiteSpace(originalLanguage = oValue as string))
|
||||
{
|
||||
args.Logger?.ILog("OriginalLanguage variable was not set.");
|
||||
|
||||
@@ -67,7 +67,7 @@ public class FfmpegBuilderSetDefaultTrack: FfmpegBuilderNode
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
bool changes = false;
|
||||
string language = args.ReplaceVariables(Language, stripMissing: true)?.ToLowerInvariant();
|
||||
string? language = args.ReplaceVariables(Language, stripMissing: true)?.ToLowerInvariant();
|
||||
if (string.IsNullOrWhiteSpace(language))
|
||||
{
|
||||
// use index
|
||||
|
||||
@@ -272,19 +272,19 @@ public class FfmpegBuilderTrackSorter : FfmpegBuilderNode
|
||||
if (comparison.StartsWith("{") && comparison.EndsWith("}"))
|
||||
{
|
||||
comparison = comparison[1..^1];
|
||||
if (args?.Variables?.TryGetValue(comparison, out object variable) == true)
|
||||
if (args?.Variables?.TryGetValue(comparison, out object? variable) == true)
|
||||
comparison = variable?.ToString() ?? string.Empty;
|
||||
else
|
||||
comparison = string.Empty;
|
||||
}
|
||||
else if (args?.Variables?.TryGetValue(comparison, out object oVariable) == true)
|
||||
else if (args?.Variables?.TryGetValue(comparison, out object? oVariable) == true)
|
||||
{
|
||||
comparison = oVariable?.ToString() ?? string.Empty;
|
||||
}
|
||||
|
||||
if (property == nameof(stream.Language))
|
||||
{
|
||||
object oOriginalLanguage = null;
|
||||
object? oOriginalLanguage = null;
|
||||
args?.Variables?.TryGetValue("OriginalLanguage", out oOriginalLanguage);
|
||||
var originalLanguage = LanguageHelper.GetIso2Code(oOriginalLanguage?.ToString() ?? string.Empty);
|
||||
comparison = string.Join("|",
|
||||
|
||||
@@ -32,7 +32,7 @@ public class FfmpegSubtitleStream : FfmpegStream
|
||||
bool containerSame =
|
||||
string.Equals(args.SourceExtension, args.DestinationExtension, StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
string destCodec;
|
||||
string? destCodec;
|
||||
if (Stream.Codec?.ToLowerInvariant().Equals("mov_text") == true &&
|
||||
args.DestinationExtension?.ToLowerInvariant()?.EndsWith("mkv") == true)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ public partial class FfmpegBuilderVideoBitrateEncode:VideoEncodeBase
|
||||
|
||||
string encoder = Environment.GetEnvironmentVariable("HW_OFF") == "1" ||
|
||||
(
|
||||
args.Variables?.TryGetValue("HW_OFF", out object oHwOff) == true && (oHwOff as bool? == true || oHwOff?.ToString() == "1")
|
||||
args.Variables?.TryGetValue("HW_OFF", out object? oHwOff) == true && (oHwOff as bool? == true || oHwOff?.ToString() == "1")
|
||||
) ? ENCODER_CPU : this.Encoder;
|
||||
|
||||
args.Logger?.ILog("Bitrate: " + Bitrate);
|
||||
@@ -155,8 +155,8 @@ public partial class FfmpegBuilderVideoBitrateEncode:VideoEncodeBase
|
||||
private static IEnumerable<string> H264(NodeParameters args, bool tenBit, string encoder, int bitrate)
|
||||
{
|
||||
List<string> parameters = new List<string>();
|
||||
string[] bit10Filters = null;
|
||||
string[] non10BitFilters = null;
|
||||
string[]? bit10Filters = null;
|
||||
string[]? non10BitFilters = null;
|
||||
if (encoder == ENCODER_CPU)
|
||||
parameters.AddRange(H26x_CPU(false, bitrate, out bit10Filters));
|
||||
else if(IsMac && encoder == ENCODER_MAC)
|
||||
@@ -199,8 +199,8 @@ public partial class FfmpegBuilderVideoBitrateEncode:VideoEncodeBase
|
||||
{
|
||||
// hevc_qsv -load_plugin hevc_hw -pix_fmt p010le -profile:v main10 -global_quality 21 -g 24 -look_ahead 1 -look_ahead_depth 60
|
||||
List<string> parameters = new List<string>();
|
||||
string[] bit10Filters = null;
|
||||
string[] non10BitFilters = null;
|
||||
string[]? bit10Filters = null;
|
||||
string[]? non10BitFilters = null;
|
||||
bool qsv = false;
|
||||
if (encoder == ENCODER_CPU)
|
||||
parameters.AddRange(H26x_CPU(true, bitrate, out bit10Filters));
|
||||
|
||||
@@ -102,7 +102,7 @@ public partial class FfmpegBuilderVideoEncode:VideoEncodeBase
|
||||
|
||||
string encoder = Environment.GetEnvironmentVariable("HW_OFF") == "1" ||
|
||||
(
|
||||
args.Variables?.TryGetValue("HW_OFF", out object oHwOff) == true && (oHwOff as bool? == true || oHwOff?.ToString() == "1")
|
||||
args.Variables?.TryGetValue("HW_OFF", out object? oHwOff) == true && (oHwOff as bool? == true || oHwOff?.ToString() == "1")
|
||||
) ? ENCODER_CPU : this.Encoder;
|
||||
|
||||
args.Logger?.ILog("Quality: " + Quality);
|
||||
@@ -171,8 +171,8 @@ public partial class FfmpegBuilderVideoEncode:VideoEncodeBase
|
||||
private static IEnumerable<string> H264(NodeParameters args, bool tenBit, int quality, string encoder, string speed)
|
||||
{
|
||||
List<string> parameters = new List<string>();
|
||||
string[] bit10Filters = null;
|
||||
string[] non10BitFilters = null;
|
||||
string[]? bit10Filters = null;
|
||||
string[]? non10BitFilters = null;
|
||||
if (encoder == ENCODER_CPU)
|
||||
parameters.AddRange(H26x_CPU(false, quality, speed, out bit10Filters));
|
||||
else if(IsMac && encoder == ENCODER_MAC)
|
||||
@@ -215,8 +215,8 @@ public partial class FfmpegBuilderVideoEncode:VideoEncodeBase
|
||||
{
|
||||
// hevc_qsv -load_plugin hevc_hw -pix_fmt p010le -profile:v main10 -global_quality 21 -g 24 -look_ahead 1 -look_ahead_depth 60
|
||||
List<string> parameters = new List<string>();
|
||||
string[] bit10Filters = null;
|
||||
string[] non10BitFilters = null;
|
||||
string[]? bit10Filters = null;
|
||||
string[]? non10BitFilters = null;
|
||||
bool qsv = false;
|
||||
if (encoder == ENCODER_CPU)
|
||||
parameters.AddRange(H26x_CPU(true, quality, speed, out bit10Filters));
|
||||
|
||||
@@ -307,7 +307,7 @@ public class CanUseHardwareEncoding:Node
|
||||
ArgumentList = arguments.ToArray(),
|
||||
Silent = true
|
||||
}).Result;
|
||||
string output = cmd.Output?.Contains("va_openDriver() returns 0") == true ? null : cmd.Output;
|
||||
string? output = cmd.Output?.Contains("va_openDriver() returns 0") == true ? null : cmd.Output;
|
||||
if (cmd.ExitCode != 0 || string.IsNullOrWhiteSpace(output) == false)
|
||||
{
|
||||
string asStr = string.Join(" ", arguments.Select(x => x.Contains(" ") ? "\"" + x + "\"" : x));
|
||||
|
||||
@@ -25,11 +25,13 @@ namespace VideoNodes.Tests
|
||||
{
|
||||
if (args == null || args.Length == 0)
|
||||
return;
|
||||
#pragma warning disable IL2026
|
||||
string message = type + " -> " +
|
||||
string.Join(", ", args.Select(x =>
|
||||
x == null ? "null" :
|
||||
x.GetType().IsPrimitive || x is string ? x.ToString() :
|
||||
System.Text.Json.JsonSerializer.Serialize(x)));
|
||||
#pragma warning restore IL2026
|
||||
Messages.Add(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,9 @@ public abstract class TestBase
|
||||
return;
|
||||
|
||||
string json = File.ReadAllText(filename);
|
||||
#pragma warning disable IL2026
|
||||
var settings = JsonSerializer.Deserialize<TestSettings>(json);
|
||||
#pragma warning restore IL2026
|
||||
this.TestPath = settings.TestPath;
|
||||
this.TempPath = settings.TempPath;
|
||||
this.FfmpegPath = settings.FfmpegPath;
|
||||
|
||||
@@ -34,8 +34,10 @@ internal class VideoMetadata
|
||||
{
|
||||
try
|
||||
{
|
||||
#pragma warning disable IL2026
|
||||
string json = JsonSerializer.Serialize(source);
|
||||
var result = JsonSerializer.Deserialize<VideoMetadata>(json);
|
||||
#pragma warning restore IL2026
|
||||
return result ?? new ();
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -233,8 +233,10 @@ namespace FileFlows.VideoNodes
|
||||
// may be from non Legacy VideoNodes
|
||||
try
|
||||
{
|
||||
#pragma warning disable IL2026
|
||||
string json = JsonSerializer.Serialize(args.Parameters[VIDEO_INFO]);
|
||||
var vi = JsonSerializer.Deserialize<VideoInfo>(json);
|
||||
#pragma warning restore IL2026
|
||||
if (vi == null)
|
||||
throw new Exception("Failed to deserailize object");
|
||||
return vi;
|
||||
|
||||
Reference in New Issue
Block a user