From 7afa36f0c666c5a49a11e800158bdd9524e84327 Mon Sep 17 00:00:00 2001 From: John Andrews Date: Fri, 7 Jul 2023 17:12:56 +1200 Subject: [PATCH 1/4] FF-1001 - Created unpack flow element --- BasicNodes/BasicNodes.csproj | 1 + BasicNodes/Tools/Unpack.cs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/BasicNodes/BasicNodes.csproj b/BasicNodes/BasicNodes.csproj index e9f7bed4..8358fbe5 100644 --- a/BasicNodes/BasicNodes.csproj +++ b/BasicNodes/BasicNodes.csproj @@ -6,6 +6,7 @@ enable 1.1.1.528 1.1.1.528 + true true FileFlows John Andrews diff --git a/BasicNodes/Tools/Unpack.cs b/BasicNodes/Tools/Unpack.cs index 85fe25d0..435827f0 100644 --- a/BasicNodes/Tools/Unpack.cs +++ b/BasicNodes/Tools/Unpack.cs @@ -53,6 +53,9 @@ public class Unpack: Node } string destDir = args.ReplaceVariables(DestinationPath, stripMissing: true, cleanSpecialCharacters: true); + destDir = args.MapPath(destDir); + if (Directory.Exists(destDir) == false) + Directory.CreateDirectory(destDir); if (fileInfo.Extension.ToLower() == ".zip") ZipFile.ExtractToDirectory(filename, destDir, true); From abdd8611ec7cceac95a53a483fa5fd2a91e1c760 Mon Sep 17 00:00:00 2001 From: John Andrews Date: Sat, 8 Jul 2023 09:33:18 +1200 Subject: [PATCH 2/4] FF-1012 - fixing issue with move folder --- BasicNodes/File/MoveFile.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/BasicNodes/File/MoveFile.cs b/BasicNodes/File/MoveFile.cs index fc2e433d..1199466c 100644 --- a/BasicNodes/File/MoveFile.cs +++ b/BasicNodes/File/MoveFile.cs @@ -159,10 +159,13 @@ public class MoveFile : Node } args.Result = NodeResult.Failure; - if (moveFolder) - dest = Path.Combine(dest, args.RelativeFile); - else - dest = Path.Combine(dest, new FileInfo(args.FileName).Name); + if (moveFolder) // we only want the full directory relative to the library, we don't want the original filename + { + dest = new FileInfo(Path.Combine(dest, args.RelativeFile)).DirectoryName; + args.Logger?.ILog("Using relative directory: " + dest); + } + + dest = Path.Combine(dest, new FileInfo(args.FileName).Name); var fiDest = new FileInfo(dest); var fiWorking = new FileInfo(args.WorkingFile); @@ -189,6 +192,8 @@ public class MoveFile : Node fiDest = new FileInfo(dest); } + args.Logger?.ILog("Final destination: " + dest); + return dest; } } \ No newline at end of file From cc46231503b1e2053d8d58fdda3a02f23dbdb38e Mon Sep 17 00:00:00 2001 From: John Andrews Date: Sat, 8 Jul 2023 09:34:19 +1200 Subject: [PATCH 3/4] FF-1012 - fixing issue with move folder --- BasicNodes/File/CopyFile.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/BasicNodes/File/CopyFile.cs b/BasicNodes/File/CopyFile.cs index 5130d9cb..89c6e17e 100644 --- a/BasicNodes/File/CopyFile.cs +++ b/BasicNodes/File/CopyFile.cs @@ -92,10 +92,13 @@ namespace FileFlows.BasicNodes.File } args.Logger.ILog($"CopyFile.Dest[2] '{dest}'"); - if (CopyFolder) - dest = Path.Combine(dest, args.RelativeFile); - else - dest = Path.Combine(dest, new FileInfo(args.FileName).Name); + if (CopyFolder) // we only want the full directory relative to the library, we don't want the original filename + { + dest = new FileInfo(Path.Combine(dest, args.RelativeFile)).DirectoryName; + args.Logger?.ILog("Using relative directory: " + dest); + } + + dest = Path.Combine(dest, new FileInfo(args.FileName).Name); args.Logger.ILog($"CopyFile.Dest[3] '{dest}'"); var fiDest = new FileInfo(dest); From 6ec7b8522194d0bbcb29324ce0d99f5d2ad5bbdc Mon Sep 17 00:00:00 2001 From: John Andrews Date: Thu, 13 Jul 2023 10:38:09 +1200 Subject: [PATCH 4/4] FF-1013 - added "strict" to ffmpeg builder executor --- DiscordNodes/ExtensionMethods.cs | 8 +++ DiscordNodes/Plugin.cs | 15 +++++ DiscordNodes/PluginSettings.cs | 33 ++++++----- VideoNodes/FFMpegEncoder.cs | 16 +++++- .../FfmpegBuilderExecutor.cs | 56 ++++++++++++------- VideoNodes/VideoNodes.en.json | 4 +- VideoNodes/VideoNodes/EncodingNode.cs | 35 ++++++++++-- 7 files changed, 124 insertions(+), 43 deletions(-) diff --git a/DiscordNodes/ExtensionMethods.cs b/DiscordNodes/ExtensionMethods.cs index 8a814624..0f9f6657 100644 --- a/DiscordNodes/ExtensionMethods.cs +++ b/DiscordNodes/ExtensionMethods.cs @@ -1,6 +1,14 @@ namespace FileFlows.DiscordNodes; +/// +/// Extension methods +/// internal static class ExtensionMethods { + /// + /// Treats an empty string as if it was null + /// + /// the input string + /// the string unless it was empty then null public static string? EmptyAsNull(this string str) => str == string.Empty ? null : str; } diff --git a/DiscordNodes/Plugin.cs b/DiscordNodes/Plugin.cs index f2b7dab1..df940bf2 100644 --- a/DiscordNodes/Plugin.cs +++ b/DiscordNodes/Plugin.cs @@ -1,11 +1,26 @@ namespace FileFlows.DiscordNodes; +/// +/// The plugin information +/// public class Plugin : FileFlows.Plugin.IPlugin { + /// + /// Gets the UID of this plugin + /// public Guid Uid => new Guid("ebaea108-8783-46b2-a889-be0d79bc8ad6"); + /// + /// Gets the name of this plugin + /// public string Name => "Discord"; + /// + /// Gets the minimum version this plugin supports + /// public string MinimumVersion => "1.0.4.2019"; + /// + /// Initializes this plugin + /// public void Init() { } diff --git a/DiscordNodes/PluginSettings.cs b/DiscordNodes/PluginSettings.cs index 509290a0..005cb43a 100644 --- a/DiscordNodes/PluginSettings.cs +++ b/DiscordNodes/PluginSettings.cs @@ -1,18 +1,21 @@ -namespace FileFlows.DiscordNodes +namespace FileFlows.DiscordNodes; + +/// +/// THe Plugin settings +/// +public class PluginSettings:IPluginSettings { - using FileFlows.Plugin; - using FileFlows.Plugin.Attributes; - using System; - using System.ComponentModel.DataAnnotations; + /// + /// Gets or sets the webhook id for this plugin + /// + [Text(1)] + [Required] + public string WebhookId { get; set; } - public class PluginSettings:IPluginSettings - { - [Text(1)] - [Required] - public string WebhookId { get; set; } - - [Text(2)] - [Required] - public string WebhookToken { get; set; } - } + /// + /// Gets or sets the webhook token for this plugin + /// + [Text(2)] + [Required] + public string WebhookToken { get; set; } } diff --git a/VideoNodes/FFMpegEncoder.cs b/VideoNodes/FFMpegEncoder.cs index bd04c5dc..63e72a06 100644 --- a/VideoNodes/FFMpegEncoder.cs +++ b/VideoNodes/FFMpegEncoder.cs @@ -26,9 +26,21 @@ namespace FileFlows.VideoNodes this.Logger = logger; } - public (bool successs, string output) Encode(string input, string output, List arguments, bool dontAddInputFile = false, bool dontAddOutputFile = false) + /// + /// Encodes using FFmpeg + /// + /// the input file + /// the output file + /// the FFmpeg arguments + /// if the input file should not be added to the arguments + /// if the output file should not be added to the arguments + /// the strictness to use + /// the result and output of the encode + public (bool successs, string output) Encode(string input, string output, List arguments, bool dontAddInputFile = false, bool dontAddOutputFile = false, string strictness = "-2") { arguments ??= new List (); + if (string.IsNullOrWhiteSpace(strictness)) + strictness = "-2"; // -y means it will overwrite a file if output already exists if (dontAddInputFile == false) { @@ -42,7 +54,7 @@ namespace FileFlows.VideoNodes if (arguments.Last() != "-") { // strict -2 needs to be just before the output file - arguments.AddRange(new[] { "-strict", "-2" }); // allow experimental stuff + arguments.AddRange(new[] { "-strict", strictness }); arguments.Add(output); } else diff --git a/VideoNodes/FfmpegBuilderNodes/FfmpegBuilderExecutor.cs b/VideoNodes/FfmpegBuilderNodes/FfmpegBuilderExecutor.cs index 21b5d51f..44eb7d81 100644 --- a/VideoNodes/FfmpegBuilderNodes/FfmpegBuilderExecutor.cs +++ b/VideoNodes/FfmpegBuilderNodes/FfmpegBuilderExecutor.cs @@ -16,9 +16,43 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode public override bool NoEditorOnAdd => true; + /// + /// Gets or sets if hardware decoding should be used + /// [DefaultValue(true)] [Boolean(1)] public bool HardwareDecoding { get; set; } + + /// + /// Gets or sets the strictness + /// + [DefaultValue("experimental")] + [Select(nameof(StrictOptions), 2)] + public string Strictness { get; set; } + + private static List _StrictOptions; + /// + /// Gets the strict options + /// + public static List StrictOptions + { + get + { + if (_StrictOptions == null) + { + _StrictOptions = new List + { + new () { Label = "Experimental", Value = "experimental" }, + new () { Label = "Unofficial", Value = "unofficial" }, + new () { Label = "Normal", Value = "normal" }, + new () { Label = "Strict", Value = "strict" }, + new () { Label = "Very", Value = "very" }, + }; + } + return _StrictOptions; + } + } + public override int Execute(NodeParameters args) { @@ -145,26 +179,6 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode ffArgs.AddRange(new[] { "-map", "0:t?", "-c:t", "copy" }); var ffmpeg = FFMPEG; - // string strFfArgs = string.Join(" ", ffArgs); - // if ((strFfArgs.Contains("libaom-av1") || strFfArgs.Contains("libsvtav1"))) - // { - // args.Logger.DLog("Using AV1"); - // if (File.Exists(ffmpeg + "-av1")) - // { - // ffmpeg = ffmpeg + "-av1"; - // if(ffArgs.IndexOf("-hwaccel") > 0) - // { - // ffArgs.RemoveRange(ffArgs.IndexOf("-hwaccel"), 2); - // if(ffArgs.IndexOf("-hwaccel_output_format") > 0) - // { - // ffArgs.RemoveRange(ffArgs.IndexOf("-hwaccel_output_format"), 2); - // } - // } - // } - // else - // args.Logger.DLog("Did not find custom FFMPEG AV1: " + ffmpeg + "-av1"); - // } - if(string.IsNullOrWhiteSpace(model.PreExecuteCode) == false) { var preExecutor = new PreExecutor(args, model.PreExecuteCode, ffArgs); @@ -178,7 +192,7 @@ public class FfmpegBuilderExecutor: FfmpegBuilderNode } - if (Encode(args, ffmpeg, ffArgs, extension, dontAddInputFile: true) == false) + if (Encode(args, ffmpeg, ffArgs, extension, dontAddInputFile: true, strictness: Strictness) == false) return -1; foreach (var file in model.InputFiles) diff --git a/VideoNodes/VideoNodes.en.json b/VideoNodes/VideoNodes.en.json index dfe91337..c8802a1a 100644 --- a/VideoNodes/VideoNodes.en.json +++ b/VideoNodes/VideoNodes.en.json @@ -62,7 +62,9 @@ "Description": "Executes a FFMPEG Builder command created by other FFMPEG Builder nodes.", "Fields": { "HardwareDecoding": "Hardware Decoding", - "HardwareDecoding-Help": "If the executor should attempt to use hardware decoding. If not available the execution will proceed just without hardware decoding enabled." + "HardwareDecoding-Help": "If the executor should attempt to use hardware decoding. If not available the execution will proceed just without hardware decoding enabled.", + "Strictness": "Strictness", + "Strictness-Help": "Allows you to customize the strictness of FFmpeg. This should be left on 'Experimental' for most users." } }, "FfmpegBuilderAddInputFile": { diff --git a/VideoNodes/VideoNodes/EncodingNode.cs b/VideoNodes/VideoNodes/EncodingNode.cs index 312e8fc1..5af23633 100644 --- a/VideoNodes/VideoNodes/EncodingNode.cs +++ b/VideoNodes/VideoNodes/EncodingNode.cs @@ -16,13 +16,40 @@ namespace FileFlows.VideoNodes private FFMpegEncoder Encoder; - public bool Encode(NodeParameters args, string ffmpegExe, List ffmpegParameters, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false) + /// + /// Encodes a video + /// + /// the node parameters + /// the FFmpeg executable + /// the FFmpeg parameters + /// the output fil extension + /// the output file + /// if the working file should be updated to the newly created file + /// if the input file should not be added to the arguments + /// if the output file should not be added to the arguments + /// the strictness to use + /// true if the encode was successful + public bool Encode(NodeParameters args, string ffmpegExe, List ffmpegParameters, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false, string strictness = "-2") { string output; - return Encode(args, ffmpegExe, ffmpegParameters, out output, extension, outputFile, updateWorkingFile, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile); + return Encode(args, ffmpegExe, ffmpegParameters, out output, extension, outputFile, updateWorkingFile, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile, strictness: strictness); } - public bool Encode(NodeParameters args, string ffmpegExe, List ffmpegParameters, out string output, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false) + /// + /// Encodes a video + /// + /// the node parameters + /// the FFmpeg executable + /// the FFmpeg parameters + /// the output from the command + /// the output fil extension + /// the output file + /// if the working file should be updated to the newly created file + /// if the input file should not be added to the arguments + /// if the output file should not be added to the arguments + /// the strictness to use + /// true if the encode was successful + public bool Encode(NodeParameters args, string ffmpegExe, List ffmpegParameters, out string output, string extension = "mkv", string outputFile = "", bool updateWorkingFile = true, bool dontAddInputFile = false, bool dontAddOutputFile = false, string strictness = "-2") { if (string.IsNullOrEmpty(extension)) extension = "mkv"; @@ -43,7 +70,7 @@ namespace FileFlows.VideoNodes } } - var success = Encoder.Encode(args.WorkingFile, outputFile, ffmpegParameters, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile); + var success = Encoder.Encode(args.WorkingFile, outputFile, ffmpegParameters, dontAddInputFile: dontAddInputFile, dontAddOutputFile: dontAddOutputFile, strictness: strictness); args.Logger.ILog("Encoding successful: " + success.successs); if (success.successs && updateWorkingFile) {