mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 08:27:44 +01:00
Fixed image sequence output
This commit is contained in:
@@ -97,9 +97,12 @@ namespace Flowframes
|
||||
return Regex.Split(str, "\r\n|\r|\n");
|
||||
}
|
||||
|
||||
public static string Trunc(this string value, int maxChars)
|
||||
public static string Trunc(this string value, int maxChars, bool addEllipsis = true)
|
||||
{
|
||||
return value.Length <= maxChars ? value : value.Substring(0, maxChars) + "…";
|
||||
string str = value.Length <= maxChars ? value : value.Substring(0, maxChars);
|
||||
if(addEllipsis)
|
||||
str += "…";
|
||||
return str;
|
||||
}
|
||||
|
||||
public static string StripBadChars(this string str)
|
||||
@@ -142,5 +145,15 @@ namespace Flowframes
|
||||
}
|
||||
return newString.ToString();
|
||||
}
|
||||
|
||||
public static string ReplaceLast (this string str, string stringToReplace, string replaceWith)
|
||||
{
|
||||
int place = str.LastIndexOf(stringToReplace);
|
||||
|
||||
if (place == -1)
|
||||
return str;
|
||||
|
||||
return str.Remove(place, stringToReplace.Length).Insert(place, replaceWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Flowframes
|
||||
{
|
||||
Interpolate.OutMode outMode = Interpolate.OutMode.VidMp4;
|
||||
if (outModeCombox.Text.ToLower().Contains("gif")) outMode = Interpolate.OutMode.VidGif;
|
||||
if (outModeCombox.Text.ToLower().Contains("png")) outMode = Interpolate.OutMode.ImgPng;
|
||||
if (outModeCombox.Text.ToLower().Contains("image")) outMode = Interpolate.OutMode.ImgPng;
|
||||
return outMode;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,13 +114,9 @@ namespace Flowframes.IO
|
||||
foreach (FileInfo fileInfo in files)
|
||||
{
|
||||
if (move)
|
||||
{
|
||||
fileInfo.MoveTo(Path.Combine(target.FullName, fileInfo.Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
fileInfo.CopyTo(Path.Combine(target.FullName, fileInfo.Name), overwrite: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,25 @@ namespace Flowframes.Main
|
||||
{
|
||||
class CreateVideo
|
||||
{
|
||||
public static async Task FramesToVideo(string path, string outPath, i.OutMode mode)
|
||||
public static async Task Export(string path, string outPath, i.OutMode mode)
|
||||
{
|
||||
if (!mode.ToString().ToLower().Contains("vid")) // Skip output mode is not a video (e.g. image sequence)
|
||||
if (!mode.ToString().ToLower().Contains("vid")) // Copy interp frames out of temp folder and skip video export for image seq export
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Log("Moving interpolated frames out of temp folder...");
|
||||
string copyPath = Path.Combine(i.currentTempDir.ReplaceLast("-temp", "-interpolated"));
|
||||
Logger.Log($"{path} -> {copyPath}");
|
||||
IOUtils.CreateDir(copyPath);
|
||||
IOUtils.Copy(path, copyPath, true);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.Log("Failed to move interp frames folder: " + e.Message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (IOUtils.GetAmountOfFiles(path, false, $"*.{InterpolateUtils.lastExt}") <= 1)
|
||||
{
|
||||
i.Cancel("Output folder does not contain frames - An error must have occured during interpolation!", AiProcess.hasShownError);
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Flowframes
|
||||
if (canceled) return;
|
||||
Program.mainForm.SetProgress(100);
|
||||
if(!currentlyUsingAutoEnc)
|
||||
await CreateVideo.FramesToVideo(interpFramesDir, nextOutPath, outMode);
|
||||
await CreateVideo.Export(interpFramesDir, nextOutPath, outMode);
|
||||
IOUtils.ReverseRenaming(AiProcess.filenameMap, true); // Get timestamps back
|
||||
Cleanup(interpFramesDir);
|
||||
Program.mainForm.SetWorking(false);
|
||||
|
||||
@@ -166,8 +166,9 @@ namespace Flowframes.Main
|
||||
|
||||
public static async Task CreateOutputVid ()
|
||||
{
|
||||
currentOutMode = Program.mainForm.GetBatchEntry().outMode;
|
||||
string outPath = Path.Combine(currentOutPath, Path.GetFileNameWithoutExtension(currentInPath) + IOUtils.GetAiSuffix(currentAi, lastInterpFactor) + InterpolateUtils.GetExt(currentOutMode));
|
||||
await CreateVideo.FramesToVideo(currentInterpFramesDir, outPath, currentOutMode);
|
||||
await CreateVideo.Export(currentInterpFramesDir, outPath, currentOutMode);
|
||||
}
|
||||
|
||||
public static async Task Reset ()
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Flowframes.Main
|
||||
basePath = custPath;
|
||||
}
|
||||
|
||||
return Path.Combine(basePath, Path.GetFileNameWithoutExtension(inPath).StripBadChars() + "-temp");
|
||||
return Path.Combine(basePath, Path.GetFileNameWithoutExtension(inPath).StripBadChars().Trunc(30, false) + "-temp");
|
||||
}
|
||||
|
||||
public static bool InputIsValid(string inDir, string outDir, float fpsOut, int interp, int tilesize)
|
||||
|
||||
Reference in New Issue
Block a user