mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-09-01 19:51:28 +02:00
Fixed weird duplicate frames problem with 2x
This commit is contained in:
@@ -103,7 +103,7 @@ namespace Flowframes
|
||||
string enc = useH265 ? "libx265" : "libx264";
|
||||
string presetStr = $"-preset {Config.Get("ffEncPreset")}";
|
||||
string vfrFilename = Path.GetFileName(framesFile);
|
||||
string args = $"-vsync 2 -f concat -i {vfrFilename} -r {fps.ToString().Replace(",", ".")} -c:v {enc} -crf {crf} {presetStr} {videoEncArgs} -threads {Config.GetInt("ffEncThreads")} -c:a copy {outPath.Wrap()}";
|
||||
string args = $"-vsync 1 -f concat -i {vfrFilename} -r {fps.ToString().Replace(",", ".")} -c:v {enc} -crf {crf} {presetStr} {videoEncArgs} -threads {Config.GetInt("ffEncThreads")} -c:a copy {outPath.Wrap()}";
|
||||
await AvProcess.RunFfmpeg(args, framesFile.GetParentDir(), logMode);
|
||||
}
|
||||
|
||||
@@ -111,9 +111,8 @@ namespace Flowframes
|
||||
{
|
||||
Logger.Log($"Merging videos...");
|
||||
string loopStr = (looptimes > 0) ? $"-stream_loop {looptimes}" : "";
|
||||
string vsyncStr = Config.GetInt("vfrMode") == 0 ? "-vsync 1" : "-vsync 2";
|
||||
string vfrFilename = Path.GetFileName(concatFile);
|
||||
string args = $" {loopStr} {vsyncStr} -f concat -r {fps.ToString().Replace(",", ".")} -i {vfrFilename} -c copy -pix_fmt yuv420p -movflags +faststart {outPath.Wrap()}";
|
||||
string args = $" {loopStr} -vsync 1 -f concat -r {fps.ToString().Replace(",", ".")} -i {vfrFilename} -c copy -pix_fmt yuv420p -movflags +faststart {outPath.Wrap()}";
|
||||
await AvProcess.RunFfmpeg(args, concatFile.GetParentDir(), AvProcess.LogMode.Hidden);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,14 +61,15 @@ namespace Flowframes.Main
|
||||
if (unencodedFrames.Count >= (chunkSize + safetyBufferFrames) || !aiRunning) // Encode every n frames, or after process has exited
|
||||
{
|
||||
busy = true;
|
||||
Logger.Log("Encoding Chunk #" + videoIndex, true, false, "ffmpeg.txt");
|
||||
|
||||
List<string> framesToEncode = aiRunning ? unencodedFrames.Take(chunkSize).ToList() : unencodedFrames; // Take all remaining frames if process is done
|
||||
Logger.Log($"Encoding Chunk #{videoIndex} using {Path.GetFileName(framesToEncode.First())} through {Path.GetFileName(framesToEncode.Last())}", true, false, "ffmpeg.txt");
|
||||
|
||||
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.currentOutMode)}");
|
||||
int firstFrameNum = Path.GetFileNameWithoutExtension(framesToEncode[0]).GetInt();
|
||||
await CreateVideo.EncodeChunk(outpath, firstFrameNum, framesToEncode.Count);
|
||||
await CreateVideo.EncodeChunk(outpath, firstFrameNum - 1, framesToEncode.Count);
|
||||
|
||||
if(Interpolate.canceled) return;
|
||||
|
||||
|
||||
@@ -150,11 +150,10 @@ namespace Flowframes.Main
|
||||
int crf = h265 ? Config.GetInt("h265Crf") : Config.GetInt("h264Crf");
|
||||
|
||||
string vfrFileOriginal = Path.Combine(i.currentTempDir, $"vfr-{i.lastInterpFactor}x.ini");
|
||||
string vfrFile = Path.Combine(i.currentTempDir, $"vfr-chunk-temp.ini");
|
||||
string vfrFile = Path.Combine(i.currentTempDir, $"vfr-chunk-{firstFrameNum}-{firstFrameNum + framesAmount}.ini");
|
||||
File.WriteAllLines(vfrFile, IOUtils.ReadLines(vfrFileOriginal).Skip(firstFrameNum * 2).Take(framesAmount * 2));
|
||||
|
||||
await FFmpegCommands.FramesToMp4Vfr(vfrFile, outPath, h265, crf, i.currentOutFps, AvProcess.LogMode.Hidden);
|
||||
IOUtils.TryDeleteIfExists(vfrFile);
|
||||
}
|
||||
|
||||
static async Task Loop(string outPath, int looptimes)
|
||||
|
||||
@@ -138,8 +138,7 @@ namespace Flowframes
|
||||
Cancel("Only a single frame was extracted from your input file!\n\nPossibly your input is an image, not a video?");
|
||||
else
|
||||
Cancel("Frame extraction failed!\n\nYour input file might be incompatible.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Config.GetInt("dedupMode") == 1)
|
||||
await MagickDedupe.Run(currentFramesPath);
|
||||
|
||||
Reference in New Issue
Block a user