mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-09-01 19:51:28 +02:00
Fixed AutoEncode with non-MP4 output formats
This commit is contained in:
@@ -69,7 +69,7 @@ namespace Flowframes
|
||||
framesFolder = Path.Combine(tempFolder, Paths.framesDir);
|
||||
interpFolder = Path.Combine(tempFolder, Paths.interpDir);
|
||||
inputIsFrames = IOUtils.IsPathDirectory(inPath);
|
||||
outFilename = Path.Combine(outPath, Path.GetFileNameWithoutExtension(inPath) + IOUtils.GetAiSuffix(ai, interpFactor) + InterpolateUtils.GetExt(outMode));
|
||||
outFilename = Path.Combine(outPath, Path.GetFileNameWithoutExtension(inPath) + IOUtils.GetAiSuffix(ai, interpFactor) + FFmpegUtils.GetExt(outMode));
|
||||
}
|
||||
|
||||
public Size GetInputRes ()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Flowframes.Data;
|
||||
using Flowframes.AudioVideo;
|
||||
using Flowframes.Data;
|
||||
using Flowframes.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -67,7 +68,7 @@ namespace Flowframes.Main
|
||||
|
||||
IOUtils.ZeroPadDir(framesToEncode, Padding.interpFrames); // Zero-pad frames before encoding to make sure filenames match with VFR file
|
||||
|
||||
string outpath = Path.Combine(videoChunksFolder, $"{videoIndex.ToString().PadLeft(4, '0')}{InterpolateUtils.GetExt(Interpolate.current.outMode)}");
|
||||
string outpath = Path.Combine(videoChunksFolder, $"{videoIndex.ToString().PadLeft(4, '0')}{FFmpegUtils.GetExt(Interpolate.current.outMode)}");
|
||||
int firstFrameNum = Path.GetFileNameWithoutExtension(framesToEncode[0]).GetInt();
|
||||
await CreateVideo.EncodeChunk(outpath, Interpolate.current.outMode, firstFrameNum - 1, framesToEncode.Count);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Windows.Forms;
|
||||
using Padding = Flowframes.Data.Padding;
|
||||
using i = Flowframes.Interpolate;
|
||||
using System.Diagnostics;
|
||||
using Flowframes.AudioVideo;
|
||||
|
||||
namespace Flowframes.Main
|
||||
{
|
||||
@@ -130,7 +131,7 @@ namespace Flowframes.Main
|
||||
|
||||
public static async Task ChunksToVideo(string chunksPath, string vfrFile, string outPath)
|
||||
{
|
||||
if (IOUtils.GetAmountOfFiles(chunksPath, false, "*.mp4") < 1)
|
||||
if (IOUtils.GetAmountOfFiles(chunksPath, false, $"*{FFmpegUtils.GetExt(i.current.outMode)}") < 1)
|
||||
{
|
||||
i.Cancel("No video chunks found - An error must have occured during chunk encoding!", AiProcess.hasShownError);
|
||||
return;
|
||||
@@ -180,9 +181,6 @@ namespace Flowframes.Main
|
||||
|
||||
public static async Task EncodeChunk(string outPath, i.OutMode mode, int firstFrameNum, int framesAmount)
|
||||
{
|
||||
bool h265 = Config.GetInt("mp4Enc") == 1;
|
||||
int crf = h265 ? Config.GetInt("h265Crf") : Config.GetInt("h264Crf");
|
||||
|
||||
string vfrFileOriginal = Path.Combine(i.current.tempFolder, $"vfr-{i.current.interpFactor}x.ini");
|
||||
string vfrFile = Path.Combine(i.current.tempFolder, $"vfr-chunk-{firstFrameNum}-{firstFrameNum + framesAmount}.ini");
|
||||
File.WriteAllLines(vfrFile, IOUtils.ReadLines(vfrFileOriginal).Skip(firstFrameNum * 2).Take(framesAmount * 2));
|
||||
|
||||
@@ -133,8 +133,9 @@ namespace Flowframes
|
||||
|
||||
public static async Task RunAi(string outpath, int targetFrames, int tilesize, AI ai, bool stepByStep = false)
|
||||
{
|
||||
bool vidMode = current.outMode.ToString().ToLower().Contains("vid");
|
||||
if ((stepByStep && Config.GetBool("sbsAllowAutoEnc")) || (!stepByStep && Config.GetInt("autoEncMode") > 0))
|
||||
currentlyUsingAutoEnc = current.outMode == OutMode.VidMp4 && IOUtils.GetAmountOfFiles(current.framesFolder, false) * current.interpFactor >= (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.1f;
|
||||
currentlyUsingAutoEnc = vidMode && IOUtils.GetAmountOfFiles(current.framesFolder, false) * current.interpFactor >= (AutoEncode.chunkSize + AutoEncode.safetyBufferFrames) * 1.1f;
|
||||
else
|
||||
currentlyUsingAutoEnc = false;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Flowframes.Data;
|
||||
using Flowframes.AudioVideo;
|
||||
using Flowframes.Data;
|
||||
using Flowframes.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -149,7 +150,7 @@ namespace Flowframes.Main
|
||||
return;
|
||||
}
|
||||
|
||||
string outPath = Path.Combine(current.outPath, Path.GetFileNameWithoutExtension(current.inPath) + IOUtils.GetAiSuffix(current.ai, current.interpFactor) + InterpolateUtils.GetExt(current.outMode));
|
||||
string outPath = Path.Combine(current.outPath, Path.GetFileNameWithoutExtension(current.inPath) + IOUtils.GetAiSuffix(current.ai, current.interpFactor) + FFmpegUtils.GetExt(current.outMode));
|
||||
await CreateVideo.Export(current.interpFolder, outPath, current.outMode);
|
||||
}
|
||||
|
||||
|
||||
@@ -270,15 +270,6 @@ namespace Flowframes.Main
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string GetExt(i.OutMode format)
|
||||
{
|
||||
if (format == i.OutMode.VidMp4)
|
||||
return ".mp4";
|
||||
if (format == i.OutMode.VidGif)
|
||||
return ".gif";
|
||||
return ".mp4";
|
||||
}
|
||||
|
||||
public static void ShowMessage(string msg, string title = "Message")
|
||||
{
|
||||
if (!BatchProcessing.busy)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Flowframes.UI
|
||||
return span.ToString(@"mm\:ss");
|
||||
|
||||
if (span.TotalSeconds >= 1f || !allowMs)
|
||||
return span.ToString(@"ss") + "s";
|
||||
return span.ToString(@"ss".TrimStart('0').PadLeft(1, '0')) + "s";
|
||||
|
||||
return span.ToString(@"fff").TrimStart('0').PadLeft(1, '0') + "ms";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user