change hardware detection to DxDiag
This commit is contained in:
parent
4408023cd6
commit
98fa171645
|
@ -1,7 +1,7 @@
|
|||
using System.Diagnostics;
|
||||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
using System.Management;
|
||||
using System.Text.RegularExpressions;
|
||||
using NAudio.CoreAudioApi;
|
||||
using NAudio.Wave;
|
||||
using System.Net;
|
||||
|
@ -282,9 +282,50 @@ class Program
|
|||
Console.WriteLine("FFmpeg recording started.");
|
||||
}
|
||||
|
||||
private static string GetGraphicsCard()
|
||||
{
|
||||
string dxDiagOutput = RunDxDiag();
|
||||
string graphicsCard = ParseGraphicsCard(dxDiagOutput);
|
||||
return graphicsCard.ToUpper();
|
||||
}
|
||||
|
||||
private static string RunDxDiag()
|
||||
{
|
||||
Process dxDiagProcess = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "dxdiag",
|
||||
Arguments = "/t dxdiag_output.txt",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = false,
|
||||
CreateNoWindow = true
|
||||
}
|
||||
};
|
||||
Console.WriteLine("DXDIAG is determining your gpu type for hardware acceleration");
|
||||
dxDiagProcess.Start();
|
||||
dxDiagProcess.WaitForExit();
|
||||
return File.ReadAllText("dxdiag_output.txt");
|
||||
}
|
||||
|
||||
private static string ParseGraphicsCard(string dxDiagOutput)
|
||||
{
|
||||
string pattern = @"Card name:\s*(.*)";
|
||||
Match match = Regex.Match(dxDiagOutput, pattern);
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
return match.Groups[1].Value;
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
|
||||
private static string GetHardwareEncoder()
|
||||
{
|
||||
var graphicsCard = GetGraphicsCard();
|
||||
Console.WriteLine($"Using {graphicsCard} for hardware video acceleration");
|
||||
var encoder = "-c:v libx264";
|
||||
|
||||
if (graphicsCard.Contains("NVIDIA"))
|
||||
|
@ -310,26 +351,6 @@ private static string GetHardwareEncoder()
|
|||
return encoder;
|
||||
}
|
||||
|
||||
private static string GetGraphicsCard()
|
||||
{
|
||||
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DisplayConfiguration");
|
||||
var graphicsCard = "";
|
||||
|
||||
foreach (ManagementObject obj in searcher.Get())
|
||||
{
|
||||
foreach (var prop in obj.Properties)
|
||||
{
|
||||
if (prop.Name == "Description" && prop.Value != null)
|
||||
{
|
||||
graphicsCard = prop.Value.ToString().ToUpper();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return graphicsCard;
|
||||
}
|
||||
|
||||
private static void StopRecording(string songName)
|
||||
{
|
||||
StopAudioRecording();
|
||||
|
|
Loading…
Reference in a new issue