Added NVDIA gpu check
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
using FFMpegCore;
|
||||
using FFMpegCore.Helpers;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Encoder;
|
||||
@@ -81,6 +83,20 @@ public class EncoderService : BackgroundService, IEncoderService {
|
||||
job.Status = JobStatus.InProgress;
|
||||
var file = job.FilePath;
|
||||
string outputPath = Path.Combine(options.TemporaryFilesPath, Path.GetFileName(job.FilePath));
|
||||
|
||||
// Determine if an NVDA graphics card is available for hardware acceleration
|
||||
ProcessStartInfo psi = new ProcessStartInfo {
|
||||
FileName = Path.Combine(options.FfmpegPath, "ffmpeg.exe"),
|
||||
Arguments = @"-hide_banner -init_hw_device ""list""",
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = true,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
using Process ffmpeg = Process.Start(psi)!;
|
||||
string output = await ffmpeg.StandardOutput.ReadToEndAsync(cancellationToken);
|
||||
await ffmpeg.WaitForExitAsync(cancellationToken);
|
||||
bool nvenc = output.Contains("cuda");
|
||||
|
||||
IEncodingStrategy strategy = job.RequestedEncoding switch {
|
||||
EncoderType.H264 => new H264EncodingStrategy(file, outputPath, job),
|
||||
EncoderType.HEVC => new HEVCEncodingStrategy(file, outputPath, job),
|
||||
|
||||
Reference in New Issue
Block a user