Fixed image sequence export copying with autoenc

This commit is contained in:
n00mkrad
2021-08-31 01:08:21 +02:00
parent df769804f1
commit 7cf5fdcf37
2 changed files with 11 additions and 13 deletions

View File

@@ -130,7 +130,7 @@ namespace Flowframes.Main
string outpath = Path.Combine(videoChunksFolder, "chunks", $"{chunkNo.ToString().PadLeft(4, '0')}{FfmpegUtils.GetExt(Interpolate.current.outMode)}"); string outpath = Path.Combine(videoChunksFolder, "chunks", $"{chunkNo.ToString().PadLeft(4, '0')}{FfmpegUtils.GetExt(Interpolate.current.outMode)}");
string firstFile = Path.GetFileName(interpFramesLines[frameLinesToEncode.First()].Trim()); string firstFile = Path.GetFileName(interpFramesLines[frameLinesToEncode.First()].Trim());
string lastFile = Path.GetFileName(interpFramesLines[frameLinesToEncode.Last()].Trim()); string lastFile = Path.GetFileName(interpFramesLines[frameLinesToEncode.Last()].Trim());
Logger.Log($"[AE] Encoding Chunk #{chunkNo} to using line {frameLinesToEncode.First()} ({firstFile}) through {frameLinesToEncode.Last()} ({lastFile})", true, false, "ffmpeg"); Logger.Log($"[AE] Encoding Chunk #{chunkNo} to using line {frameLinesToEncode.First()} ({firstFile}) through {frameLinesToEncode.Last()} ({lastFile}) - {unencodedFrameLines.Count} unencoded frames left in total", true, false, "ffmpeg");
await CreateVideo.EncodeChunk(outpath, Interpolate.current.interpFolder, chunkNo, Interpolate.current.outMode, frameLinesToEncode.First(), frameLinesToEncode.Count); await CreateVideo.EncodeChunk(outpath, Interpolate.current.interpFolder, chunkNo, Interpolate.current.outMode, frameLinesToEncode.First(), frameLinesToEncode.Count);

View File

@@ -88,25 +88,24 @@ namespace Flowframes.Main
Logger.Log($"Exporting {desiredFormat.ToUpper()} frames to '{Path.GetFileName(outputFolderPath)}'..."); Logger.Log($"Exporting {desiredFormat.ToUpper()} frames to '{Path.GetFileName(outputFolderPath)}'...");
if (desiredFormat.ToUpper() == availableFormat.ToUpper()) // Move if frames are already in the desired format if (desiredFormat.ToUpper() == availableFormat.ToUpper()) // Move if frames are already in the desired format
await CopyOutputFrames(framesPath, framesFile, outputFolderPath, fpsLimit); await CopyOutputFrames(framesPath, framesFile, outputFolderPath, 1, fpsLimit, false);
else // Encode if frames are not in desired format else // Encode if frames are not in desired format
await FfmpegEncode.FramesToFrames(framesFile, outputFolderPath, 0, I.current.outFps, new Fraction(), desiredFormat); await FfmpegEncode.FramesToFrames(framesFile, outputFolderPath, 1, I.current.outFps, new Fraction(), desiredFormat);
} }
if (fpsLimit) if (fpsLimit)
{ {
string outputFolderPath = Path.Combine(I.current.outPath, await IoUtils.GetCurrentExportFilename(true, false)); string outputFolderPath = Path.Combine(I.current.outPath, await IoUtils.GetCurrentExportFilename(true, false));
Logger.Log($"Exporting {desiredFormat.ToUpper()} frames to '{Path.GetFileName(outputFolderPath)}' (Resampled to {maxFps} FPS)..."); Logger.Log($"Exporting {desiredFormat.ToUpper()} frames to '{Path.GetFileName(outputFolderPath)}' (Resampled to {maxFps} FPS)...");
await FfmpegEncode.FramesToFrames(framesFile, outputFolderPath, 0, I.current.outFps, maxFps, desiredFormat); await FfmpegEncode.FramesToFrames(framesFile, outputFolderPath, 1, I.current.outFps, maxFps, desiredFormat);
} }
if (!stepByStep) if (!stepByStep)
await IoUtils.DeleteContentsOfDirAsync(I.current.interpFolder); await IoUtils.DeleteContentsOfDirAsync(I.current.interpFolder);
} }
static async Task CopyOutputFrames(string framesPath, string framesFile, string outputFolderPath, bool dontMove) static async Task CopyOutputFrames(string framesPath, string framesFile, string outputFolderPath, int startNo, bool dontMove, bool hideLog)
{ {
await IoUtils.TryDeleteIfExistsAsync(outputFolderPath);
IoUtils.CreateDir(outputFolderPath); IoUtils.CreateDir(outputFolderPath);
Stopwatch sw = new Stopwatch(); Stopwatch sw = new Stopwatch();
sw.Restart(); sw.Restart();
@@ -118,7 +117,8 @@ namespace Flowframes.Main
string line = framesLines[idx - 1]; string line = framesLines[idx - 1];
string inFilename = line.RemoveComments().Split('/').Last().Remove("'").Trim(); string inFilename = line.RemoveComments().Split('/').Last().Remove("'").Trim();
string framePath = Path.Combine(framesPath, inFilename); string framePath = Path.Combine(framesPath, inFilename);
string outFilename = Path.Combine(outputFolderPath, idx.ToString().PadLeft(Padding.interpFrames, '0')) + Path.GetExtension(framePath); string outFilename = Path.Combine(outputFolderPath, startNo.ToString().PadLeft(Padding.interpFrames, '0')) + Path.GetExtension(framePath);
startNo++;
if (dontMove || ((idx < framesLines.Length) && framesLines[idx].Contains(inFilename))) // If file is re-used in the next line, copy instead of move if (dontMove || ((idx < framesLines.Length) && framesLines[idx].Contains(inFilename))) // If file is re-used in the next line, copy instead of move
File.Copy(framePath, outFilename); File.Copy(framePath, outFilename);
@@ -128,7 +128,7 @@ namespace Flowframes.Main
if (sw.ElapsedMilliseconds >= 500 || idx == framesLines.Length) if (sw.ElapsedMilliseconds >= 500 || idx == framesLines.Length)
{ {
sw.Restart(); sw.Restart();
Logger.Log($"Moving output frames... {idx}/{framesLines.Length}", false, true); Logger.Log($"Moving output frames... {idx}/{framesLines.Length}", hideLog, true);
await Task.Delay(1); await Task.Delay(1);
} }
} }
@@ -239,23 +239,21 @@ namespace Flowframes.Main
if (mode.ToString().ToLower().StartsWith("img")) // Image Sequence output mode, not video if (mode.ToString().ToLower().StartsWith("img")) // Image Sequence output mode, not video
{ {
//await FfmpegEncode.FramesToFrames(framesFileChunk, outPath, I.current.outFps, maxFps, Config.Get(Config.Key.imgSeqFormat).ToUpper(), AvProcess.LogMode.Hidden);
string desiredFormat = Config.Get(Config.Key.imgSeqFormat); string desiredFormat = Config.Get(Config.Key.imgSeqFormat);
string availableFormat = Path.GetExtension(IoUtils.GetFilesSorted(interpDir)[0]).Remove(".").ToUpper(); string availableFormat = Path.GetExtension(IoUtils.GetFilesSorted(interpDir)[0]).Remove(".").ToUpper();
if (!dontEncodeFullFpsVid) if (!dontEncodeFullFpsVid)
{ {
string outputFolderPath = Path.Combine(I.current.outPath, await IoUtils.GetCurrentExportFilename(false, false)); string outputFolderPath = Path.Combine(I.current.outPath, await IoUtils.GetCurrentExportFilename(false, false));
int startNumber = IoUtils.GetAmountOfFiles(outputFolderPath, false) + 1; int startNo = IoUtils.GetAmountOfFiles(outputFolderPath, false) + 1;
if(chunkNo == 1) // Only check for existing folder on first chunk, otherwise each chunk makes a new folder if(chunkNo == 1) // Only check for existing folder on first chunk, otherwise each chunk makes a new folder
IoUtils.RenameExistingFolder(outputFolderPath); IoUtils.RenameExistingFolder(outputFolderPath);
if (desiredFormat.ToUpper() == availableFormat.ToUpper()) // Move if frames are already in the desired format if (desiredFormat.ToUpper() == availableFormat.ToUpper()) // Move if frames are already in the desired format
await CopyOutputFrames(interpDir, framesFileChunk, outputFolderPath, fpsLimit); await CopyOutputFrames(interpDir, framesFileChunk, outputFolderPath, startNo, fpsLimit, true);
else // Encode if frames are not in desired format else // Encode if frames are not in desired format
await FfmpegEncode.FramesToFrames(framesFileChunk, outputFolderPath, startNumber, I.current.outFps, new Fraction(), desiredFormat, AvProcess.LogMode.Hidden); await FfmpegEncode.FramesToFrames(framesFileChunk, outputFolderPath, startNo, I.current.outFps, new Fraction(), desiredFormat, AvProcess.LogMode.Hidden);
} }
if (fpsLimit) if (fpsLimit)