EXR stuff & error handling

This commit is contained in:
N00MKRAD
2024-06-24 11:36:43 +02:00
parent 73dcbe619a
commit ff23080453
5 changed files with 17 additions and 7 deletions

View File

@@ -55,6 +55,7 @@ namespace Flowframes.Data
Name = DirectoryInfo.Name;
SourcePath = DirectoryInfo.FullName;
Format = "Folder";
IoUtils.GetFileInfosSorted(SourcePath, false, "*.*").Take(1).ToList().ForEach(f => Format = f.Extension.Trim('.'));
if (requestFpsInputIfUnset && InputRate == null)
InputRate = InterpolateUtils.AskForFramerate(Name);

View File

@@ -23,8 +23,15 @@ namespace Flowframes.IO
{
public static Image GetImage(string path, bool allowMagickFallback = true, bool log = true)
{
var incompatibleExtensions = new List<string>() { "EXR" };
try
{
string ext = new FileInfo(path).Extension.TrimStart('.').ToUpper();
if (incompatibleExtensions.Contains(ext))
return null;
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
return Image.FromStream(stream);
}

View File

@@ -19,8 +19,7 @@ namespace Flowframes.Main
if (!File.Exists(modelsFile))
{
Logger.Log($"File does not exist: {modelsFile}", true);
Logger.Log($"Error: File models.json is missing for {ai.NameInternal}, can't load AI models for this implementation!");
Logger.Log($"Error: '{modelsFile}' is missing for {ai.NameInternal}, can't load AI models for this implementation!", true);
return new ModelCollection(ai);
}

View File

@@ -91,7 +91,8 @@ namespace Flowframes.Media
}
else if (settings.Encoder == Enums.Encoding.Encoder.Exr)
{
filters.Add($"zscale=transfer=linear,format={settings.PixelFormat.ToString().Lower()}".Wrap());
if(Interpolate.currentMediaFile.Format.Upper() != "EXR")
filters.Add($"zscale=transfer=linear,format={settings.PixelFormat.ToString().Lower()}".Wrap());
}
filters.Add(GetPadFilter());

View File

@@ -4,6 +4,7 @@ using Flowframes.MiscUtils;
using Flowframes.Ui;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -72,7 +73,7 @@ namespace Flowframes.Os
l.Add($"if os.path.isdir(r'{s.InterpSettings.tempFolder}'):");
l.Add($" indexFilePath = r'{Path.Combine(s.InterpSettings.tempFolder, "cache.lwi")}'");
l.Add($"clip = core.lsmas.LWLibavSource(inputPath, cachefile=indexFilePath)"); // Load video with lsmash
l.Add("clip = core.text.FrameNum(clip, alignment=7)");
l.Add(Debugger.IsAttached ? "clip = core.text.FrameNum(clip, alignment=7)" : "");
l.Add(GetDedupeLines(s));
}
@@ -104,7 +105,8 @@ namespace Flowframes.Os
if (s.Dedupe && !s.Realtime)
l.Add(GetRedupeLines(s));
bool use470bg = loadFrames && Interpolate.currentMediaFile.Format.Upper() != "GIF";
Console.WriteLine($"In Format: {Interpolate.currentMediaFile.Format.Upper()}");
bool use470bg = loadFrames && !new[] { "GIF", "EXR" }.Contains(Interpolate.currentMediaFile.Format.Upper());
l.Add($"clip = vs.core.resize.Bicubic(clip, format=vs.YUV444P16, matrix_s={(use470bg ? "'470bg'" : "cMatrix")})"); // Convert RGB to YUV. Always use 470bg if input is YUV frames
if (!s.Dedupe) // Ignore trimming code when using deduping that that already handles trimming in the frame order file
@@ -205,7 +207,7 @@ namespace Flowframes.Os
s += " reorderedClip = reorderedClip + clip[i]\n";
s += "\n";
s += "clip = reorderedClip.std.Trim(1, reorderedClip.num_frames - 1)\n";
s += "clip = core.text.FrameNum(clip, alignment=4)\n";
s += Debugger.IsAttached ? "clip = core.text.FrameNum(clip, alignment=4)\n" : "";
s += "\n";
return s;
@@ -225,7 +227,7 @@ namespace Flowframes.Os
s += " reorderedClip = reorderedClip + clip[i]\n";
s += "\n";
s += "clip = reorderedClip.std.Trim(1, reorderedClip.num_frames - 1)\n";
s += "clip = core.text.FrameNum(clip, alignment=1)\n";
s += Debugger.IsAttached ? "clip = core.text.FrameNum(clip, alignment=1)\n" : "";
s += "\n";
return s;