mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-02-24 04:00:49 +01:00
Logging/formatting stuff + Skip RefreshExtensions if no frames are used
This commit is contained in:
@@ -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> { 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);
|
||||
|
||||
@@ -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})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -494,5 +494,11 @@ namespace Flowframes
|
||||
|
||||
return strings.Any(v => s.ToString().Equals(v.ToString(), strComp));
|
||||
}
|
||||
|
||||
/// <summary> Returns <paramref name="or"/> if the string is null or empty, otherwise returns the original string. </summary>
|
||||
public static string Or (this string s, string or = "")
|
||||
{
|
||||
return string.IsNullOrEmpty(s) ? or : s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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...");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(); };
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user