mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Symlink to frame sequence if compatible (no copying)
This commit is contained in:
@@ -59,6 +59,7 @@ namespace Flowframes
|
||||
{
|
||||
if (str.Length < 1 || str == null)
|
||||
return 0f;
|
||||
|
||||
string num = str.TrimNumbers(true).Replace(",", ".");
|
||||
float value;
|
||||
float.TryParse(num, NumberStyles.Any, CultureInfo.InvariantCulture, out value);
|
||||
|
||||
@@ -282,6 +282,7 @@ namespace Flowframes.IO
|
||||
allowConsecutiveSceneChanges,
|
||||
allowCustomInputRate,
|
||||
allowSymlinkEncoding,
|
||||
allowSymlinkImport,
|
||||
audioSubTransferMode,
|
||||
autoDedupFrames,
|
||||
autoEncDebug,
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Flowframes.IO
|
||||
return false;
|
||||
}
|
||||
|
||||
public static async Task CreateSymlinksParallel(Dictionary<string, string> pathsLinkTarget, int maxThreads = 150)
|
||||
public static async Task CreateSymlinksParallel(Dictionary<string, string> pathsLinkTarget, bool debug = false, int maxThreads = 150)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Restart();
|
||||
@@ -40,7 +40,10 @@ namespace Flowframes.IO
|
||||
|
||||
Task forEach = Task.Run(async () => Parallel.ForEach(pathsLinkTarget, opts, pair =>
|
||||
{
|
||||
CreateSymbolicLink(pair.Key, pair.Value, Flag.Unprivileged);
|
||||
bool success = CreateSymbolicLink(pair.Key, pair.Value, Flag.Unprivileged);
|
||||
|
||||
if (debug)
|
||||
Logger.Log($"Created Symlink - Source: '{pair.Key}' - Target: '{pair.Value}' - Sucess: {success}", true);
|
||||
}));
|
||||
|
||||
while (!forEach.IsCompleted) await Task.Delay(1);
|
||||
|
||||
@@ -92,29 +92,47 @@ namespace Flowframes.Media
|
||||
DeleteSource(inputFile);
|
||||
}
|
||||
|
||||
public static async Task ImportImagesCheckCompat(string inpath, string outpath, bool alpha, Size size, bool showLog, string format)
|
||||
public static async Task ImportImagesCheckCompat(string inPath, string outPath, bool alpha, Size size, bool showLog, string format)
|
||||
{
|
||||
bool compatible = await Task.Run(async () => { return AreImagesCompatible(inpath, Config.GetInt(Config.Key.maxVidHeight)); });
|
||||
bool compatible = await Task.Run(async () => { return AreImagesCompatible(inPath, Config.GetInt(Config.Key.maxVidHeight)); });
|
||||
|
||||
if (!alpha && compatible)
|
||||
{
|
||||
if (showLog) Logger.Log($"Copying images from {new DirectoryInfo(inpath).Name}...");
|
||||
Directory.CreateDirectory(outpath);
|
||||
|
||||
await Task.Run(async () => {
|
||||
int counter = 0;
|
||||
foreach (FileInfo file in IOUtils.GetFileInfosSorted(inpath))
|
||||
{
|
||||
string newFilename = counter.ToString().PadLeft(Padding.inputFrames, '0') + file.Extension;
|
||||
File.Copy(file.FullName, Path.Combine(outpath, newFilename));
|
||||
counter++;
|
||||
}
|
||||
});
|
||||
await CopyImages(inPath, outPath, showLog);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
await ImportImages(inpath, outpath, alpha, size, showLog, format);
|
||||
await ImportImages(inPath, outPath, alpha, size, showLog, format);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task CopyImages (string inpath, string outpath, bool showLog)
|
||||
{
|
||||
if (showLog) Logger.Log($"Copying images from {new DirectoryInfo(inpath).Name}...");
|
||||
Directory.CreateDirectory(outpath);
|
||||
|
||||
Dictionary<string, string> moveFromTo = new Dictionary<string, string>();
|
||||
int counter = 0;
|
||||
|
||||
foreach (FileInfo file in IOUtils.GetFileInfosSorted(inpath))
|
||||
{
|
||||
string newFilename = counter.ToString().PadLeft(Padding.inputFrames, '0') + file.Extension;
|
||||
moveFromTo.Add(file.FullName, Path.Combine(outpath, newFilename));
|
||||
counter++;
|
||||
}
|
||||
|
||||
if (Config.GetBool(Config.Key.allowSymlinkEncoding) && Config.GetBool(Config.Key.allowSymlinkImport, true))
|
||||
{
|
||||
Dictionary<string, string> moveFromToSwapped = moveFromTo.ToDictionary(x => x.Value, x => x.Key); // From/To => To/From (Link/Target)
|
||||
await Symlinks.CreateSymlinksParallel(moveFromToSwapped);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Run(async () => {
|
||||
foreach (KeyValuePair<string, string> moveFromToPair in moveFromTo)
|
||||
File.Copy(moveFromToPair.Key, moveFromToPair.Value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user