mirror of https://github.com/n00mkrad/flowframes
Added 4x/8x support for RIFE-NCNN, added CFR/VFR option
This commit is contained in:
parent
fb30d7230d
commit
6b0797f11c
|
@ -17,6 +17,10 @@
|
|||
<assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -71,7 +71,10 @@ namespace Flowframes
|
|||
string enc = useH265 ? "libx265" : "libx264";
|
||||
string loopStr = (looptimes > 0) ? $"-stream_loop {looptimes}" : "";
|
||||
string presetStr = $"-preset {Config.Get("ffEncPreset")}";
|
||||
string args = $" {loopStr} -vsync 1 -f concat -safe 0 -i {framesFile.Wrap()} -r {fps.ToString().Replace(",", ".")} -c:v {enc} -crf {crf} {presetStr} {videoEncArgs} -threads {Config.GetInt("ffEncThreads")} -c:a copy {outPath.Wrap()}";
|
||||
//Logger.Log("#1");
|
||||
string vsyncStr = Config.GetInt("vfrMode") == 0 ? "-vsync 1" : "-vsync 2";
|
||||
//Logger.Log("#2");
|
||||
string args = $" {loopStr} {vsyncStr} -f concat -safe 0 -i {framesFile.Wrap()} -r {fps.ToString().Replace(",", ".")} -c:v {enc} -crf {crf} {presetStr} {videoEncArgs} -threads {Config.GetInt("ffEncThreads")} -c:a copy {outPath.Wrap()}";
|
||||
await AvProcess.RunFfmpeg(args, AvProcess.LogMode.OnlyLastLine);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="packages\OpenCvSharp4.runtime.win.4.5.0.20201013\build\net\OpenCvSharp4.runtime.win.props" Condition="Exists('packages\OpenCvSharp4.runtime.win.4.5.0.20201013\build\net\OpenCvSharp4.runtime.win.props')" />
|
||||
<Import Project="packages\Costura.Fody.4.1.0\build\Costura.Fody.props" Condition="Exists('packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
|
@ -94,19 +95,40 @@
|
|||
<Reference Include="NvAPIWrapper, Version=0.8.0.98, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
|
||||
<HintPath>packages\NvAPIWrapper.Net.0.8.0.98\lib\net45\NvAPIWrapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
|
||||
<HintPath>packages\OpenCvSharp4.4.5.0.20201013\lib\net461\OpenCvSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenCvSharp.Blob, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
|
||||
<HintPath>packages\OpenCvSharp4.4.5.0.20201013\lib\net461\OpenCvSharp.Blob.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenCvSharp.Extensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
|
||||
<HintPath>packages\OpenCvSharp4.4.5.0.20201013\lib\net461\OpenCvSharp.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PagedControl, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\PagedControl.2.2.0\lib\net35\PagedControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Drawing.Common.5.0.0\lib\net461\System.Drawing.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Claims, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Security.Claims.4.3.0\lib\net46\System.Security.Claims.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
@ -311,6 +333,7 @@
|
|||
<Error Condition="!Exists('packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Costura.Fody.4.1.0\build\Costura.Fody.props'))" />
|
||||
<Error Condition="!Exists('packages\7z.NET.1.0.3\build\7z.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\7z.NET.1.0.3\build\7z.NET.targets'))" />
|
||||
<Error Condition="!Exists('packages\Fody.6.3.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Fody.6.3.0\build\Fody.targets'))" />
|
||||
<Error Condition="!Exists('packages\OpenCvSharp4.runtime.win.4.5.0.20201013\build\net\OpenCvSharp4.runtime.win.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\OpenCvSharp4.runtime.win.4.5.0.20201013\build\net\OpenCvSharp4.runtime.win.props'))" />
|
||||
</Target>
|
||||
<Import Project="packages\7z.NET.1.0.3\build\7z.NET.targets" Condition="Exists('packages\7z.NET.1.0.3\build\7z.NET.targets')" />
|
||||
<Import Project="packages\Fody.6.3.0\build\Fody.targets" Condition="Exists('packages\Fody.6.3.0\build\Fody.targets')" />
|
||||
|
|
|
@ -1107,12 +1107,13 @@
|
|||
// tilesizeNotAvailLabel
|
||||
//
|
||||
this.tilesizeNotAvailLabel.ForeColor = System.Drawing.Color.Silver;
|
||||
this.tilesizeNotAvailLabel.Location = new System.Drawing.Point(278, 131);
|
||||
this.tilesizeNotAvailLabel.Location = new System.Drawing.Point(278, 127);
|
||||
this.tilesizeNotAvailLabel.Margin = new System.Windows.Forms.Padding(8, 0, 3, 0);
|
||||
this.tilesizeNotAvailLabel.Name = "tilesizeNotAvailLabel";
|
||||
this.tilesizeNotAvailLabel.Size = new System.Drawing.Size(203, 24);
|
||||
this.tilesizeNotAvailLabel.Size = new System.Drawing.Size(203, 25);
|
||||
this.tilesizeNotAvailLabel.TabIndex = 37;
|
||||
this.tilesizeNotAvailLabel.Text = "Not available for the selected AI.";
|
||||
this.tilesizeNotAvailLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.tilesizeNotAvailLabel.Visible = false;
|
||||
//
|
||||
// label1
|
||||
|
|
|
@ -239,8 +239,8 @@ namespace Flowframes
|
|||
{
|
||||
if (initialized && GetAi().aiName == Networks.rifeNcnn.aiName && interpFactorCombox.SelectedIndex != 0)
|
||||
{
|
||||
MessageBox.Show("RIFE-NCNN currently only supports x2 interpolation.");
|
||||
interpFactorCombox.SelectedIndex = 0; // TODO: Add RIFE 4x/8x workaround & improve CAIN workaround
|
||||
//MessageBox.Show("RIFE-NCNN currently only supports x2 interpolation.");
|
||||
//interpFactorCombox.SelectedIndex = 0; // TODO: Add RIFE 4x/8x workaround & improve CAIN workaround
|
||||
}
|
||||
UpdateOutputFPS();
|
||||
}
|
||||
|
|
|
@ -130,6 +130,8 @@
|
|||
this.cmdDebugMode = new System.Windows.Forms.ComboBox();
|
||||
this.titleLabel = new System.Windows.Forms.Label();
|
||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.label48 = new System.Windows.Forms.Label();
|
||||
this.vfrMode = new System.Windows.Forms.ComboBox();
|
||||
this.settingsTabList.SuspendLayout();
|
||||
this.generalTab.SuspendLayout();
|
||||
this.tabListPage2.SuspendLayout();
|
||||
|
@ -204,12 +206,14 @@
|
|||
// tempDirBrowseBtn
|
||||
//
|
||||
this.tempDirBrowseBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.tempDirBrowseBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.tempDirBrowseBtn.ForeColor = System.Drawing.Color.White;
|
||||
this.tempDirBrowseBtn.Location = new System.Drawing.Point(709, 66);
|
||||
this.tempDirBrowseBtn.Name = "tempDirBrowseBtn";
|
||||
this.tempDirBrowseBtn.Size = new System.Drawing.Size(50, 23);
|
||||
this.tempDirBrowseBtn.TabIndex = 70;
|
||||
this.tempDirBrowseBtn.Text = "Browse";
|
||||
this.tempDirBrowseBtn.UseVisualStyleBackColor = false;
|
||||
this.tempDirBrowseBtn.Click += new System.EventHandler(this.tempDirBrowseBtn_Click);
|
||||
//
|
||||
// tempDirCustom
|
||||
|
@ -1146,6 +1150,8 @@
|
|||
// debugTab
|
||||
//
|
||||
this.debugTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
this.debugTab.Controls.Add(this.vfrMode);
|
||||
this.debugTab.Controls.Add(this.label48);
|
||||
this.debugTab.Controls.Add(this.ffEncPreset);
|
||||
this.debugTab.Controls.Add(this.label47);
|
||||
this.debugTab.Controls.Add(this.label46);
|
||||
|
@ -1222,7 +1228,7 @@
|
|||
//
|
||||
this.label41.AutoSize = true;
|
||||
this.label41.ForeColor = System.Drawing.Color.Silver;
|
||||
this.label41.Location = new System.Drawing.Point(308, 250);
|
||||
this.label41.Location = new System.Drawing.Point(308, 280);
|
||||
this.label41.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label41.Name = "label41";
|
||||
this.label41.Size = new System.Drawing.Size(423, 13);
|
||||
|
@ -1233,7 +1239,7 @@
|
|||
// ffprobeCountFrames
|
||||
//
|
||||
this.ffprobeCountFrames.AutoSize = true;
|
||||
this.ffprobeCountFrames.Location = new System.Drawing.Point(280, 250);
|
||||
this.ffprobeCountFrames.Location = new System.Drawing.Point(280, 280);
|
||||
this.ffprobeCountFrames.Name = "ffprobeCountFrames";
|
||||
this.ffprobeCountFrames.Size = new System.Drawing.Size(15, 14);
|
||||
this.ffprobeCountFrames.TabIndex = 73;
|
||||
|
@ -1242,7 +1248,7 @@
|
|||
// label40
|
||||
//
|
||||
this.label40.AutoSize = true;
|
||||
this.label40.Location = new System.Drawing.Point(10, 250);
|
||||
this.label40.Location = new System.Drawing.Point(10, 280);
|
||||
this.label40.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label40.Name = "label40";
|
||||
this.label40.Size = new System.Drawing.Size(162, 13);
|
||||
|
@ -1277,7 +1283,7 @@
|
|||
this.ffEncThreads.Location = new System.Drawing.Point(280, 190);
|
||||
this.ffEncThreads.MinimumSize = new System.Drawing.Size(4, 21);
|
||||
this.ffEncThreads.Name = "ffEncThreads";
|
||||
this.ffEncThreads.Size = new System.Drawing.Size(250, 21);
|
||||
this.ffEncThreads.Size = new System.Drawing.Size(250, 20);
|
||||
this.ffEncThreads.TabIndex = 70;
|
||||
//
|
||||
// label37
|
||||
|
@ -1367,6 +1373,31 @@
|
|||
this.titleLabel.TabIndex = 1;
|
||||
this.titleLabel.Text = "Settings";
|
||||
//
|
||||
// label48
|
||||
//
|
||||
this.label48.AutoSize = true;
|
||||
this.label48.Location = new System.Drawing.Point(10, 250);
|
||||
this.label48.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label48.Name = "label48";
|
||||
this.label48.Size = new System.Drawing.Size(88, 13);
|
||||
this.label48.TabIndex = 79;
|
||||
this.label48.Text = "Timestamp Mode";
|
||||
//
|
||||
// vfrMode
|
||||
//
|
||||
this.vfrMode.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.vfrMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.vfrMode.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.vfrMode.ForeColor = System.Drawing.Color.White;
|
||||
this.vfrMode.FormattingEnabled = true;
|
||||
this.vfrMode.Items.AddRange(new object[] {
|
||||
"CFR (Reduplicate Or Drop Frames)",
|
||||
"VFR (Extend Or Drop Frames)"});
|
||||
this.vfrMode.Location = new System.Drawing.Point(280, 247);
|
||||
this.vfrMode.Name = "vfrMode";
|
||||
this.vfrMode.Size = new System.Drawing.Size(250, 21);
|
||||
this.vfrMode.TabIndex = 80;
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -1504,5 +1535,7 @@
|
|||
private System.Windows.Forms.Label label47;
|
||||
private System.Windows.Forms.Label label46;
|
||||
private System.Windows.Forms.Label label45;
|
||||
private System.Windows.Forms.ComboBox vfrMode;
|
||||
private System.Windows.Forms.Label label48;
|
||||
}
|
||||
}
|
|
@ -77,6 +77,7 @@ namespace Flowframes.Forms
|
|||
ConfigParser.SaveGuiElement(ffEncThreads);
|
||||
ConfigParser.SaveGuiElement(ffEncPreset);
|
||||
ConfigParser.SaveGuiElement(ffprobeCountFrames);
|
||||
ConfigParser.SaveGuiElement(vfrMode);
|
||||
}
|
||||
|
||||
void LoadSettings()
|
||||
|
@ -116,6 +117,7 @@ namespace Flowframes.Forms
|
|||
ConfigParser.LoadGuiElement(ffEncThreads);
|
||||
ConfigParser.LoadGuiElement(ffEncPreset);
|
||||
ConfigParser.LoadGuiElement(ffprobeCountFrames);
|
||||
ConfigParser.LoadGuiElement(vfrMode);
|
||||
}
|
||||
|
||||
private void dedupThresh_Leave(object sender, EventArgs e)
|
||||
|
|
|
@ -49,8 +49,10 @@ namespace Flowframes.IO
|
|||
for (int i = 0; i < cachedLines.Length; i++)
|
||||
{
|
||||
string[] keyValuePair = cachedLines[i].Split('|');
|
||||
if (keyValuePair[0] == key)
|
||||
if (keyValuePair[0] == key && !string.IsNullOrWhiteSpace(keyValuePair[1]))
|
||||
{
|
||||
return keyValuePair[1];
|
||||
}
|
||||
}
|
||||
return WriteDefaultValIfExists(key);
|
||||
}
|
||||
|
@ -103,6 +105,7 @@ namespace Flowframes.IO
|
|||
// Debug / Other / Experimental
|
||||
if (key == "ffprobeCountFrames") return WriteDefault("ffprobeCountFrames", "False");
|
||||
if (key == "ffEncPreset") return WriteDefault("ffEncPreset", "medium");
|
||||
if (key == "ffEncPreset") return WriteDefault("ffEncPreset", "medium");
|
||||
// Tile Sizes
|
||||
if (key == "tilesize_RIFE_NCNN") return WriteDefault("tilesize_RIFE_NCNN", "2048");
|
||||
if (key == "tilesize_DAIN_NCNN") return WriteDefault("tilesize_DAIN_NCNN", "512");
|
||||
|
|
|
@ -133,6 +133,8 @@ namespace Flowframes
|
|||
if (Config.GetInt("dedupMode") == 1)
|
||||
await MagickDedupe.Run(framesPath);
|
||||
|
||||
if (canceled) return;
|
||||
|
||||
if (Config.GetInt("timingMode") == 1 && Config.GetInt("dedupMode") != 0)
|
||||
await VfrDedupe.CreateTimecodeFile(framesPath, Config.GetBool("enableLoop"), interpFactor, firstFrameFix);
|
||||
|
||||
|
@ -161,7 +163,7 @@ namespace Flowframes
|
|||
await AiProcess.RunRifeCuda(framesPath, interpFactor);
|
||||
|
||||
if (ai.aiName == Networks.rifeNcnn.aiName)
|
||||
await AiProcess.RunRifeNcnn(framesPath, outpath, interpFactor, tilesize);
|
||||
await AiProcess.RunRifeNcnnMulti(framesPath, outpath, tilesize, interpFactor);
|
||||
}
|
||||
|
||||
public static async void GetProgressByFrameAmount(string outdir, int target)
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Flowframes
|
|||
|
||||
public static Process currentAiProcess;
|
||||
public static Stopwatch processTime = new Stopwatch();
|
||||
public static Stopwatch processTimeMulti = new Stopwatch();
|
||||
|
||||
public static int lastStartupTimeMs = 1000;
|
||||
|
||||
|
@ -39,7 +40,7 @@ namespace Flowframes
|
|||
string dainDir = Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(Packages.dainNcnn.fileName));
|
||||
Process dain = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
Init(dain, 1500);
|
||||
dain.StartInfo.Arguments = $"{OSUtils.GetHiddenCmdArg()} cd /D {dainDir.Wrap()} & dain-ncnn-vulkan.exe {args} -f {InterpolateUtils.lastExt}";
|
||||
dain.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {dainDir.Wrap()} & dain-ncnn-vulkan.exe {args} -f {InterpolateUtils.lastExt}";
|
||||
Logger.Log("Running DAIN...", false);
|
||||
Logger.Log("cmd.exe " + dain.StartInfo.Arguments, true);
|
||||
if (!OSUtils.ShowHiddenCmd())
|
||||
|
@ -64,6 +65,7 @@ namespace Flowframes
|
|||
|
||||
public static async Task RunCainNcnnMulti (string framesPath, string outPath, int tilesize, int times)
|
||||
{
|
||||
processTimeMulti.Restart();
|
||||
Logger.Log("Running CAIN...", false);
|
||||
|
||||
string args = $" -v -i {framesPath.Wrap()} -o {outPath.Wrap()} -t {tilesize} -g {Config.Get("ncnnGpus")}";
|
||||
|
@ -98,7 +100,7 @@ namespace Flowframes
|
|||
if (Interpolate.canceled) return;
|
||||
Magick.MagickDedupe.ZeroPadDir(outPath, InterpolateUtils.lastExt, 8);
|
||||
|
||||
Logger.Log($"Done running CAIN - Interpolation took " + FormatUtils.Time(processTime.Elapsed));
|
||||
Logger.Log($"Done running CAIN - Interpolation took " + FormatUtils.Time(processTimeMulti.Elapsed));
|
||||
processTime.Stop();
|
||||
}
|
||||
|
||||
|
@ -108,7 +110,7 @@ namespace Flowframes
|
|||
string cainExe = "cain-ncnn-vulkan.exe";
|
||||
Process cain = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
Init(cain, 1500);
|
||||
cain.StartInfo.Arguments = $"{OSUtils.GetHiddenCmdArg()} cd /D {cainDir.Wrap()} & {cainExe} {args} -f {InterpolateUtils.lastExt}";
|
||||
cain.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {cainDir.Wrap()} & {cainExe} {args} -f {InterpolateUtils.lastExt}";
|
||||
Logger.Log("cmd.exe " + cain.StartInfo.Arguments, true);
|
||||
if (!OSUtils.ShowHiddenCmd())
|
||||
{
|
||||
|
@ -122,7 +124,6 @@ namespace Flowframes
|
|||
cain.BeginErrorReadLine();
|
||||
}
|
||||
while (!cain.HasExited) await Task.Delay(1);
|
||||
|
||||
}
|
||||
|
||||
public static async Task RunRifeCuda(string framesPath, int interpFactor)
|
||||
|
@ -135,7 +136,7 @@ namespace Flowframes
|
|||
Process rifePy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
Init(rifePy, 3000, "png");
|
||||
string args = $" --input {framesPath.Wrap()} --times {(int)Math.Log(interpFactor, 2)}";
|
||||
rifePy.StartInfo.Arguments = $"{OSUtils.GetHiddenCmdArg()} cd /D {rifeDir.Wrap()} & " +
|
||||
rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeCuda).Wrap()} & " +
|
||||
$"set CUDA_VISIBLE_DEVICES={Config.Get("torchGpus")} & {Python.GetPyCmd()} {script} {args} --imgformat {InterpolateUtils.lastExt}";
|
||||
Logger.Log($"Running RIFE ({script})...", false);
|
||||
Logger.Log("cmd.exe " + rifePy.StartInfo.Arguments, true);
|
||||
|
@ -150,8 +151,7 @@ namespace Flowframes
|
|||
rifePy.BeginOutputReadLine();
|
||||
rifePy.BeginErrorReadLine();
|
||||
}
|
||||
while (!rifePy.HasExited)
|
||||
await Task.Delay(1);
|
||||
while (!rifePy.HasExited) await Task.Delay(1);
|
||||
Logger.Log($"Done running RIFE - Interpolation took " + FormatUtils.Time(processTime.Elapsed));
|
||||
processTime.Stop();
|
||||
}
|
||||
|
@ -159,11 +159,9 @@ namespace Flowframes
|
|||
public static async Task RunRifeNcnn (string framesPath, string outPath, int interpFactor, int tilesize)
|
||||
{
|
||||
string args = $" -v -i {framesPath.Wrap()} -o {outPath.Wrap()} -t {tilesize} -g {Config.Get("ncnnGpus")} -f {InterpolateUtils.lastExt} -j 4:{Config.Get("ncnnThreads")}:4";
|
||||
|
||||
string dir = Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(Packages.rifeNcnn.fileName));
|
||||
Process rifeNcnn = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
Init(rifeNcnn, 750);
|
||||
rifeNcnn.StartInfo.Arguments = $"{OSUtils.GetHiddenCmdArg()} cd /D {dir.Wrap()} & rife-ncnn-vulkan.exe {args}";
|
||||
rifeNcnn.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeNcnn).Wrap()} & rife-ncnn-vulkan.exe {args}";
|
||||
Logger.Log("Running RIFE...", false);
|
||||
Logger.Log("cmd.exe " + rifeNcnn.StartInfo.Arguments, true);
|
||||
if (!OSUtils.ShowHiddenCmd())
|
||||
|
@ -177,8 +175,7 @@ namespace Flowframes
|
|||
rifeNcnn.BeginOutputReadLine();
|
||||
rifeNcnn.BeginErrorReadLine();
|
||||
}
|
||||
while (!rifeNcnn.HasExited)
|
||||
await Task.Delay(1);
|
||||
while (!rifeNcnn.HasExited) await Task.Delay(1);
|
||||
|
||||
if (Interpolate.canceled) return;
|
||||
Magick.MagickDedupe.ZeroPadDir(outPath, InterpolateUtils.lastExt, 8);
|
||||
|
@ -186,6 +183,67 @@ namespace Flowframes
|
|||
processTime.Stop();
|
||||
}
|
||||
|
||||
public static async Task RunRifeNcnnMulti(string framesPath, string outPath, int tilesize, int times)
|
||||
{
|
||||
processTimeMulti.Restart();
|
||||
Logger.Log("Running RIFE...", false);
|
||||
|
||||
string args = $" -v -i {framesPath.Wrap()} -o {outPath.Wrap()} -t {tilesize} -g {Config.Get("ncnnGpus")} -f {InterpolateUtils.lastExt} -j 4:{Config.Get("ncnnThreads")}:4";
|
||||
await RunRifePartial(args);
|
||||
|
||||
if (times == 4 || times == 8) // #2
|
||||
{
|
||||
if (Interpolate.canceled) return;
|
||||
Logger.Log("Re-Running RIFE for 4x interpolation...", false);
|
||||
string run1ResultsPath = outPath + "-run1";
|
||||
IOUtils.TryDeleteIfExists(run1ResultsPath);
|
||||
Directory.Move(outPath, run1ResultsPath);
|
||||
Directory.CreateDirectory(outPath);
|
||||
args = $" -v -i {run1ResultsPath.Wrap()} -o {outPath.Wrap()} -t {tilesize} -g {Config.Get("ncnnGpus")} -f {InterpolateUtils.lastExt} -j 4:{Config.Get("ncnnThreads")}:4";
|
||||
await RunRifePartial(args);
|
||||
Directory.Delete(run1ResultsPath, true);
|
||||
}
|
||||
|
||||
if (times == 8) // #3
|
||||
{
|
||||
if (Interpolate.canceled) return;
|
||||
Logger.Log("Re-Running RIFE for 8x interpolation...", false);
|
||||
string run2ResultsPath = outPath + "-run2";
|
||||
IOUtils.TryDeleteIfExists(run2ResultsPath);
|
||||
Directory.Move(outPath, run2ResultsPath);
|
||||
Directory.CreateDirectory(outPath);
|
||||
args = $" -v -i {run2ResultsPath.Wrap()} -o {outPath.Wrap()} -t {tilesize} -g {Config.Get("ncnnGpus")} -f {InterpolateUtils.lastExt} -j 4:{Config.Get("ncnnThreads")}:4";
|
||||
await RunRifePartial(args);
|
||||
Directory.Delete(run2ResultsPath, true);
|
||||
}
|
||||
|
||||
if (Interpolate.canceled) return;
|
||||
Magick.MagickDedupe.ZeroPadDir(outPath, InterpolateUtils.lastExt, 8);
|
||||
|
||||
Logger.Log($"Done running RIFE - Interpolation took " + FormatUtils.Time(processTimeMulti.Elapsed));
|
||||
processTime.Stop();
|
||||
}
|
||||
|
||||
static async Task RunRifePartial(string args)
|
||||
{
|
||||
Process rifeNcnn = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
|
||||
Init(rifeNcnn, 1500);
|
||||
rifeNcnn.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeNcnn).Wrap()} & rife-ncnn-vulkan.exe {args} -f {InterpolateUtils.lastExt} -j 4:{Config.Get("ncnnThreads")}:4";
|
||||
Logger.Log("cmd.exe " + rifeNcnn.StartInfo.Arguments, true);
|
||||
if (!OSUtils.ShowHiddenCmd())
|
||||
{
|
||||
rifeNcnn.OutputDataReceived += (sender, outLine) => { LogOutput("[O] " + outLine.Data, "rife-ncnn-log.txt"); };
|
||||
rifeNcnn.ErrorDataReceived += (sender, outLine) => { LogOutput("[E] " + outLine.Data, "rife-ncnn-log.txt"); };
|
||||
}
|
||||
rifeNcnn.Start();
|
||||
if (!OSUtils.ShowHiddenCmd())
|
||||
{
|
||||
rifeNcnn.BeginOutputReadLine();
|
||||
rifeNcnn.BeginErrorReadLine();
|
||||
}
|
||||
while (!rifeNcnn.HasExited) await Task.Delay(1);
|
||||
}
|
||||
|
||||
static void LogOutput (string line, string logFilename)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Flowframes.OS
|
|||
}
|
||||
}
|
||||
|
||||
public static string GetHiddenCmdArg()
|
||||
public static string GetCmdArg()
|
||||
{
|
||||
bool stayOpen = Config.GetInt("cmdDebugMode") == 2;
|
||||
if (stayOpen)
|
||||
|
|
|
@ -13,9 +13,16 @@
|
|||
<package id="Microsoft-WindowsAPICodePack-Core" version="1.1.4" targetFramework="net472" />
|
||||
<package id="Microsoft-WindowsAPICodePack-Shell" version="1.1.4" targetFramework="net472" />
|
||||
<package id="NvAPIWrapper.Net" version="0.8.0.98" targetFramework="net472" />
|
||||
<package id="OpenCvSharp4" version="4.5.0.20201013" targetFramework="net472" />
|
||||
<package id="OpenCvSharp4.runtime.win" version="4.5.0.20201013" targetFramework="net472" />
|
||||
<package id="OpenCvSharp4.Windows" version="4.5.0.20201013" targetFramework="net472" />
|
||||
<package id="PagedControl" version="2.2.0" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Drawing.Common" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Management" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net472" />
|
||||
<package id="System.Security.Claims" version="4.3.0" targetFramework="net472" />
|
||||
<package id="System.Security.Principal.Windows" version="4.3.0" targetFramework="net472" />
|
||||
<package id="TabControl" version="2.1.2" targetFramework="net472" />
|
||||
|
|
Loading…
Reference in New Issue