forked from Mercury/2dxAutoClip
Added support for cached DxDiag output
This commit is contained in:
parent
507e17ec14
commit
d6010162fc
|
@ -46,7 +46,7 @@ class Program
|
|||
private static void DownloadFFmpeg()
|
||||
{
|
||||
const string ffmpegExe = "ffmpeg.exe";
|
||||
const string ffmpegUrl = "https://tfm2.mercurio.moe/ffmpeg.exe"; // Replace with actual URL
|
||||
const string ffmpegUrl = "https://tfm2.mercurio.moe/ffmpeg.exe";
|
||||
|
||||
if (File.Exists(ffmpegExe))
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ class Program
|
|||
var path = line["path:".Length..].Trim();
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
_ffmpegFolderPath = path; // Recording path
|
||||
_ffmpegFolderPath = path;
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -284,28 +284,54 @@ class Program
|
|||
|
||||
private static string GetGraphicsCard()
|
||||
{
|
||||
string dxDiagOutput = RunDxDiag();
|
||||
string dxDiagOutput = GetDxDiagOutput();
|
||||
string graphicsCard = ParseGraphicsCard(dxDiagOutput);
|
||||
return graphicsCard.ToUpper();
|
||||
}
|
||||
|
||||
private static string RunDxDiag()
|
||||
private static string GetDxDiagOutput()
|
||||
{
|
||||
string dxDiagFilePath = "dxdiag_output.txt";
|
||||
if (File.Exists(dxDiagFilePath))
|
||||
{
|
||||
DateTime fileCreationTime = File.GetLastWriteTime(dxDiagFilePath);
|
||||
DateTime oneWeekAgo = DateTime.Now.AddDays(-7);
|
||||
if (fileCreationTime > oneWeekAgo)
|
||||
{
|
||||
Console.WriteLine("Using cached dxdiag_output.txt.");
|
||||
Console.WriteLine("Delete your cached dxdiag_output.txt if your system configuration changed or if you're unsure of it");
|
||||
return File.ReadAllText(dxDiagFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("dxdiag_output.txt is older than a week, regenerating...");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("dxdiag_output.txt does not exist, generating...");
|
||||
}
|
||||
return RunDxDiag(dxDiagFilePath);
|
||||
}
|
||||
|
||||
private static string RunDxDiag(string dxDiagFilePath)
|
||||
{
|
||||
Process dxDiagProcess = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "dxdiag",
|
||||
Arguments = "/t dxdiag_output.txt",
|
||||
Arguments = $"/t {dxDiagFilePath}",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = false,
|
||||
CreateNoWindow = true
|
||||
}
|
||||
};
|
||||
Console.WriteLine("DXDIAG is determining your gpu type for hardware acceleration");
|
||||
Console.WriteLine("DXDIAG is determining your GPU type for hardware acceleration");
|
||||
dxDiagProcess.Start();
|
||||
dxDiagProcess.WaitForExit();
|
||||
return File.ReadAllText("dxdiag_output.txt");
|
||||
|
||||
return File.ReadAllText(dxDiagFilePath);
|
||||
}
|
||||
|
||||
private static string ParseGraphicsCard(string dxDiagOutput)
|
||||
|
@ -321,7 +347,6 @@ class Program
|
|||
return "Unknown";
|
||||
}
|
||||
|
||||
|
||||
private static string GetHardwareEncoder()
|
||||
{
|
||||
var graphicsCard = GetGraphicsCard();
|
||||
|
@ -345,7 +370,9 @@ private static string GetHardwareEncoder()
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
Console.WriteLine("No recognized hardware encoder found, using CPU (libx264).");
|
||||
Console.WriteLine("Cpu encoding might present some graphical glitches such as desync at the end of the video or really slow framerates");
|
||||
}
|
||||
|
||||
return encoder;
|
||||
|
|
Loading…
Reference in a new issue