diff --git a/CodeLegacy/Data/InterpSettings.cs b/CodeLegacy/Data/InterpSettings.cs index c3849bc..baea1b9 100644 --- a/CodeLegacy/Data/InterpSettings.cs +++ b/CodeLegacy/Data/InterpSettings.cs @@ -62,7 +62,7 @@ namespace Flowframes get { if (_scaledResolution.IsEmpty) - _scaledResolution = InterpolateUtils.GetInterpolationResolution(FfmpegCommands.ModuloMode.Disabled, InputResolution); + _scaledResolution = InterpolateUtils.GetInterpolationResolution(FfmpegCommands.ModuloMode.Any, InputResolution); return _scaledResolution; } } @@ -97,7 +97,7 @@ namespace Flowframes _inputResolution = new Size(0, 0); noRedupe = dedupe && interpFactor == 1; SetPaths(inPath); - RefreshExtensions(ai: ai); + RefreshExtensions(ai: ai, settings: this); } private void SetPaths(string inputPath) @@ -119,13 +119,13 @@ namespace Flowframes { if (Interpolate.currentMediaFile != null && !Interpolate.currentMediaFile.MayHaveAlpha) { - Logger.Log($"RefreshAlpha: Input video does not have alpha channel.", true); + Logger.Log($"[RefreshAlpha] Input video does not have alpha channel.", true, toConsole: Cli.Verbose); return; } string noAlphaReason = CantUseAlphaReason(vs); alpha = string.IsNullOrEmpty(noAlphaReason); - Logger.Log($"RefreshAlpha: Alpha {(alpha ? "enabled" : $"disabled: {noAlphaReason}")}", true); + Logger.Log($"[RefreshAlpha] Alpha {(alpha ? "enabled" : $"disabled: {noAlphaReason}")}", true); if (!alpha) { @@ -138,7 +138,7 @@ namespace Flowframes } catch (Exception e) { - Logger.Log("RefreshAlpha Error: " + e.Message, true); + Logger.Log("[RefreshAlpha] Error: " + e.Message, true); alpha = false; } } @@ -153,10 +153,10 @@ namespace Flowframes var supportedEncoders = new List { Enc.Png, Enc.Gif, Enc.Webp, Enc.Exr, Enc.Tiff, Enc.ProResKs, Enc.VpxVp9, Enc.Ffv1, Enc.Huffyuv }; - if(!supportedEncoders.Contains(outSettings.Encoder)) + if (!supportedEncoders.Contains(outSettings.Encoder)) return $"Selected encoder ({Strings.Encoder.Get($"{outSettings.Encoder}", returnKeyInsteadOfEmptyString: true)}) does not support alpha."; - if(!OutputUtils.AlphaFormats.Contains(outSettings.PixelFormat)) + if (!OutputUtils.AlphaFormats.Contains(outSettings.PixelFormat)) return $"Selected pixel format ({Strings.PixelFormat.Get($"{outSettings.PixelFormat}", returnKeyInsteadOfEmptyString: true)}) does not support alpha."; return ""; @@ -164,7 +164,7 @@ namespace Flowframes public enum FrameType { Import, Interp, Both }; - public void RefreshExtensions(FrameType type = FrameType.Both, AiInfo ai = null) + public void RefreshExtensions(FrameType type = FrameType.Both, AiInfo ai = null, InterpSettings settings = null) { if (ai == null) { @@ -174,6 +174,10 @@ namespace Flowframes ai = Interpolate.currentSettings.ai; } + // If using piped interpolation and both input & output are video formats, no frame I/O is involved, making this irrelevant + if (ai.Piped && settings != null && !settings.inputIsFrames && settings.outSettings != null && settings.outSettings.Format != Enums.Output.Format.Images) + return; + bool pngOutput = outSettings.Encoder == Enc.Png; bool aviHqChroma = outSettings.Format == Enums.Output.Format.Avi && OutputUtils.AlphaFormats.Contains(outSettings.PixelFormat); bool proresHqChroma = outSettings.Encoder == Enc.ProResKs && OutputUtils.AlphaFormats.Contains(outSettings.PixelFormat); diff --git a/CodeLegacy/Data/Streams/Stream.cs b/CodeLegacy/Data/Streams/Stream.cs index 05abd33..684d5ee 100644 --- a/CodeLegacy/Data/Streams/Stream.cs +++ b/CodeLegacy/Data/Streams/Stream.cs @@ -14,7 +14,7 @@ public override string ToString() { - return $"Stream #{Index.ToString().PadLeft(2, '0')}{(IsDefault ? "*" : "")} {Type} ({Codec})"; + return $"Stream #{Index.ToString().PadLeft(2, '0')}{(IsDefault ? "*" : " ")} {Type} ({Codec})"; } } } diff --git a/CodeLegacy/Data/VidExtraData.cs b/CodeLegacy/Data/VidExtraData.cs index 33290e3..3c4006d 100644 --- a/CodeLegacy/Data/VidExtraData.cs +++ b/CodeLegacy/Data/VidExtraData.cs @@ -23,7 +23,7 @@ namespace Flowframes.Data public bool HasAllColorValues => ColSpace.IsNotEmpty() && ColRange.IsNotEmpty() && ColTransfer.IsNotEmpty() && ColPrimaries.IsNotEmpty(); public bool HasAnyColorValues => ColSpace.IsNotEmpty() || ColRange.IsNotEmpty() || ColTransfer.IsNotEmpty() || ColPrimaries.IsNotEmpty(); - public string ColorsStr => $"Color Primaries {(ColPrimaries.IsEmpty() ? "unset" : ColPrimaries)}, Space {(ColSpace.IsEmpty() ? "unset" : ColSpace)}, Transfer {(ColTransfer.IsEmpty() ? "unset" : ColTransfer)}, Range {(ColRange.IsEmpty() ? "unset" : ColRange)}"; + public string ColorsStr => $"Color Primaries {ColPrimaries.Or("unset")}, Colorspace {ColSpace.Or("unset")}, Transfer {ColTransfer.Or("unset")}, Color Range {ColRange.Or("unset")}"; public VidExtraData() { } @@ -70,7 +70,7 @@ namespace Flowframes.Data } } - Logger.Log($"{ColorsStr}; SAR {Sar.Wrap()}, DAR {Dar.Wrap()}, Rot. {Rotation}", true, false, "ffmpeg"); + Logger.Log($"{ColorsStr}; SAR {Sar.Wrap()}, DAR {Dar.Wrap()}{(Rotation != 0 ? $", Rotation {Rotation}°" : "")}", true, false, "ffmpeg"); } // FFmpeg -colorspace (matrix coefficients) diff --git a/CodeLegacy/Extensions/ExtensionMethods.cs b/CodeLegacy/Extensions/ExtensionMethods.cs index c39046c..8b8c6f6 100644 --- a/CodeLegacy/Extensions/ExtensionMethods.cs +++ b/CodeLegacy/Extensions/ExtensionMethods.cs @@ -494,5 +494,11 @@ namespace Flowframes return strings.Any(v => s.ToString().Equals(v.ToString(), strComp)); } + + /// Returns if the string is null or empty, otherwise returns the original string. + public static string Or (this string s, string or = "") + { + return string.IsNullOrEmpty(s) ? or : s; + } } } diff --git a/CodeLegacy/Forms/Main/Form1.cs b/CodeLegacy/Forms/Main/Form1.cs index 1be2bf1..8e7a563 100644 --- a/CodeLegacy/Forms/Main/Form1.cs +++ b/CodeLegacy/Forms/Main/Form1.cs @@ -348,14 +348,11 @@ namespace Flowframes.Forms.Main public void SetStatus(string str) { - Logger.Log(str, true); + Logger.Log($"[Status] {str}", true); statusLabel.Text = str; } - public string GetStatus() - { - return statusLabel.Text; - } + public string Status => statusLabel.Text; public void SetProgress(int percent) { @@ -601,7 +598,7 @@ namespace Flowframes.Forms.Main public void SetWorking(bool state, bool allowCancel = true) { - Logger.Log($"SetWorking({state})", true); + Logger.Log(state ? "Working..." : "Done.", true); SetProgress(-1); Control[] controlsToDisable = new Control[] { runBtn, runStepBtn, stepSelector, settingsBtn }; Control[] controlsToHide = new Control[] { runBtn, runStepBtn, stepSelector }; diff --git a/CodeLegacy/IO/IoUtils.cs b/CodeLegacy/IO/IoUtils.cs index f456ff0..a08079e 100644 --- a/CodeLegacy/IO/IoUtils.cs +++ b/CodeLegacy/IO/IoUtils.cs @@ -787,7 +787,7 @@ namespace Flowframes.IO } if (log) - Logger.Log($"Computed {hashType} for '{Path.GetFileNameWithoutExtension(path).Trunc(40) + Path.GetExtension(path)}' ({GetFilesizeStr(path)}): {hashStr} ({sw})", true); + Logger.Log($"Computed {hashType} for '{Path.GetFileNameWithoutExtension(path).Trunc(40) + Path.GetExtension(path)}' ({GetFilesizeStr(path)}): {hashStr} ({sw})", true, toConsole: Cli.Verbose); return hashStr; } diff --git a/CodeLegacy/IO/ModelDownloader.cs b/CodeLegacy/IO/ModelDownloader.cs index 1334672..b27426b 100644 --- a/CodeLegacy/IO/ModelDownloader.cs +++ b/CodeLegacy/IO/ModelDownloader.cs @@ -136,7 +136,7 @@ namespace Flowframes.IO { string aiDir = ai.PkgDir; - Logger.Log($"DownloadModelFiles(string ai = {ai.NameInternal}, string model = {modelDir}, bool log = {log})", true); + Logger.Log($"Loading model files for {ai.NameInternal} - Model: {modelDir}", true); try { diff --git a/CodeLegacy/Magick/Blend.cs b/CodeLegacy/Magick/Blend.cs index dc899c1..e7673a5 100644 --- a/CodeLegacy/Magick/Blend.cs +++ b/CodeLegacy/Magick/Blend.cs @@ -30,7 +30,7 @@ namespace Flowframes.Magick string[] framesLines = fileContent.SplitIntoLines(); // Array with frame filenames - string oldStatus = Program.mainForm.GetStatus(); + string oldStatus = Program.mainForm.Status; if (setStatus) Program.mainForm.SetStatus("Blending scene transitions..."); diff --git a/CodeLegacy/Main/Interpolate.cs b/CodeLegacy/Main/Interpolate.cs index f4fd1a6..685f7f2 100644 --- a/CodeLegacy/Main/Interpolate.cs +++ b/CodeLegacy/Main/Interpolate.cs @@ -106,7 +106,7 @@ namespace Flowframes if (canceled) return; - Program.mainForm.Invoke(() => Program.mainForm.SetStatus("Downloading models...")); + Program.mainForm.Invoke(() => Program.mainForm.SetStatus("Loading model...")); await ModelDownloader.DownloadModelFiles(currentSettings.ai, currentSettings.model.Dir); if (canceled) return; diff --git a/CodeLegacy/Main/InterpolateUtils.cs b/CodeLegacy/Main/InterpolateUtils.cs index f95f6f4..1c30300 100644 --- a/CodeLegacy/Main/InterpolateUtils.cs +++ b/CodeLegacy/Main/InterpolateUtils.cs @@ -257,7 +257,9 @@ namespace Flowframes.Main if (print && factor < 1f) Logger.Log($"Video is bigger than the maximum - Downscaling to {width}x{height}."); - Logger.Log($"Scaled input res {inputRes.Width}x{inputRes.Height} to {res.Width}x{res.Height} ({moduloMode})", true); + if(inputRes != res) + Logger.Log($"Scaled input resolution {inputRes.Width}x{inputRes.Height} to {res.Width}x{res.Height} (Modulo: {modulo}/{moduloMode})", true); + return res; } @@ -268,9 +270,7 @@ namespace Flowframes.Main if (divisibleBy == 0) return numberInt; - return onlyRoundUp - ? (int)Math.Ceiling((double)number / divisibleBy) * divisibleBy - : (int)Math.Round((double)number / divisibleBy) * divisibleBy; + return onlyRoundUp ? (int)Math.Ceiling((double)number / divisibleBy) * divisibleBy : (int)Math.Round((double)number / divisibleBy) * divisibleBy; } public static bool CanUseAutoEnc(bool stepByStep, InterpSettings current) @@ -279,46 +279,43 @@ namespace Flowframes.Main if (current.ai.Piped) { - Logger.Log($"Not Using AutoEnc: Using piped encoding.", true); + Logger.Log($"Auto-Encode is off: Not applicable for piped encoding.", true, toConsole: false); return false; } if (current.outSettings.Format == Enums.Output.Format.Gif) { - Logger.Log($"Not Using AutoEnc: Using GIF output", true); + Logger.Log($"Auto-Encode is off: Not supported for {current.outSettings.Format.ToString().Upper()} output.", true); return false; } if (stepByStep && !Config.GetBool(Config.Key.sbsAllowAutoEnc)) { - Logger.Log($"Not Using AutoEnc: Using step-by-step mode, but 'sbsAllowAutoEnc' is false", true); + Logger.Log($"Auto-Encode is off: Using step-by-step mode, but {nameof(Config.Key.sbsAllowAutoEnc)} is false.", true); return false; } if (!stepByStep && Config.GetInt(Config.Key.autoEncMode) == 0) { - Logger.Log($"Not Using AutoEnc: 'autoEncMode' is 0", true); + Logger.Log($"Auto-Encode is off: Disabled in settings ({nameof(Config.Key.autoEncMode)}).", true); return false; } int inFrames = IoUtils.GetAmountOfFiles(current.framesFolder, false); if (inFrames * current.interpFactor < (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.2f) { - Logger.Log($"Not Using AutoEnc: Input frames ({inFrames}) * factor ({current.interpFactor}) is smaller than (chunkSize ({AutoEncode.chunkSize}) + safetyBufferFrames ({AutoEncode.safetyBufferFrames}) * 1.2f)", true); + Logger.Log($"Auto-Encode is off: Not enough frames for chunking.", true); return false; } return true; } - public static bool UseUhd() + public static bool UseUhd(Size? outputRes = null) { - return UseUhd(I.currentSettings.OutputResolution); - } - - public static bool UseUhd(Size outputRes) - { - return outputRes.Height >= Config.GetInt(Config.Key.uhdThresh); + if (outputRes == null) + outputRes = I.currentSettings.OutputResolution; + return outputRes.Value.Height >= Config.GetInt(Config.Key.uhdThresh); } public static void FixConsecutiveSceneFrames(string sceneFramesPath, string sourceFramesPath) @@ -358,7 +355,7 @@ namespace Flowframes.Main public static Fraction AskForFramerate(string mediaName, bool isImageSequence = true) { - string text = $"Please enter the source frame rate for{(isImageSequence ? " the image sequence" : "")} '{mediaName.Trunc(80)}'."; + string text = $"Please enter the source frame rate (before interpolation) for{(isImageSequence ? " the image sequence" : "")} '{mediaName.Trunc(80)}'."; var form = new PromptForm("Enter Frame Rate", text, "15"); form.ShowDialog(); return new Fraction(form.EnteredText); diff --git a/CodeLegacy/Media/AvProcess.cs b/CodeLegacy/Media/AvProcess.cs index d4b683a..81228b4 100644 --- a/CodeLegacy/Media/AvProcess.cs +++ b/CodeLegacy/Media/AvProcess.cs @@ -70,7 +70,7 @@ namespace Flowframes ffmpeg.StartInfo.Arguments = $"/C cd /D {GetAvDir().Wrap()} & ffmpeg {beforeArgs} {args}"; if (logMode != LogMode.Hidden) Logger.Log("Running FFmpeg...", false); - Logger.Log($"ffmpeg {beforeArgs} {args}", true, false, "ffmpeg"); + Logger.Log($"ffmpeg {beforeArgs} {args}", true, false, "ffmpeg", toConsole: Cli.Verbose); ffmpeg.OutputDataReceived += (sender, outLine) => { AvOutputHandler.LogOutput(outLine.Data, ref processOutput, "ffmpeg", logMode, progressBar); timeSinceLastOutput.Sw.Restart(); }; ffmpeg.ErrorDataReceived += (sender, outLine) => { AvOutputHandler.LogOutput(outLine.Data, ref processOutput, "ffmpeg", logMode, progressBar); timeSinceLastOutput.Sw.Restart(); }; diff --git a/CodeLegacy/Media/FfmpegCommands.cs b/CodeLegacy/Media/FfmpegCommands.cs index 181d092..7c578b7 100644 --- a/CodeLegacy/Media/FfmpegCommands.cs +++ b/CodeLegacy/Media/FfmpegCommands.cs @@ -42,7 +42,7 @@ namespace Flowframes return wrap ? filters.Wrap() : filters; } - public enum ModuloMode { Disabled, ForInterpolation, ForEncoding } + public enum ModuloMode { Any, ForInterpolation, ForEncoding } public static int GetModulo(ModuloMode mode) { diff --git a/CodeLegacy/Media/FfmpegUtils.cs b/CodeLegacy/Media/FfmpegUtils.cs index 9f50fa8..1d8ceaf 100644 --- a/CodeLegacy/Media/FfmpegUtils.cs +++ b/CodeLegacy/Media/FfmpegUtils.cs @@ -549,7 +549,7 @@ namespace Flowframes.Media // If all are supported, simply copy all streams if (supported.All(x => x.Value)) { - Logger.Log($"All audio codecs are supported by {outFormat}, copying all.", true, false); + Logger.Log($"[Mux] All audio codecs are supported by {outFormat}, copying all.", true, false); return "-map 1:a -c:a copy"; } @@ -564,7 +564,7 @@ namespace Flowframes.Media relIdx++; } - Logger.Log($"{outFormat} audio handling: {log.TrimEnd(' ', '-')}", true, false); + Logger.Log($"[Mux] {outFormat} audio handling: {log.TrimEnd(' ', '-')}", true, false); return args.TrimEnd(); } @@ -594,7 +594,7 @@ namespace Flowframes.Media // If all are supported, simply copy all streams if (codec.All(x => x.Value == "copy")) { - Logger.Log($"All subtitle codecs are supported by {outFormat}, copying all.", true, false); + Logger.Log($"[Mux] All subtitle codecs are supported by {outFormat}, copying all.", true, false); return "-map 1:s -c:s copy"; } @@ -609,7 +609,7 @@ namespace Flowframes.Media relIdx++; } - Logger.Log($"{outFormat} subtitle handling: {log.TrimEnd(' ', '-')}", true, false); + Logger.Log($"[Mux] {outFormat} subtitle handling: {log.TrimEnd(' ', '-')}", true, false); return args.TrimEnd(); } diff --git a/CodeLegacy/Media/GetMediaResolutionCached.cs b/CodeLegacy/Media/GetMediaResolutionCached.cs index fa07099..d860d87 100644 --- a/CodeLegacy/Media/GetMediaResolutionCached.cs +++ b/CodeLegacy/Media/GetMediaResolutionCached.cs @@ -31,7 +31,7 @@ namespace Flowframes.Media cache.Add(hash, size); } - Logger.Log($"Resolution of '{Path.GetFileName(path)}': {size.Width}x{size.Height}", true); + Logger.Log($"Resolution of '{Path.GetFileName(path)}': {size.Width}x{size.Height}", true, toConsole: Cli.Verbose); return size; } diff --git a/CodeLegacy/Ui/InterpolationProgress.cs b/CodeLegacy/Ui/InterpolationProgress.cs index c24b0bb..7d1dbf9 100644 --- a/CodeLegacy/Ui/InterpolationProgress.cs +++ b/CodeLegacy/Ui/InterpolationProgress.cs @@ -95,7 +95,7 @@ namespace Flowframes.Ui { targetFrames = target; Restart(); - Logger.Log($"Starting GetProgressFromFfmpegLog() loop for log '{logFile}', target is {target} frames", true); + Logger.Log($"Starting loop for reading progress from log '{logFile}', target is {target} frames", true); UpdateInterpProgress(0, targetFrames); while (Program.busy)