Added NVDIA gpu check
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -330,3 +330,5 @@ fabric.properties
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
#FFMPEG binaries
|
||||
/Encoder/ffmpeg/*
|
||||
@@ -18,4 +18,17 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="ffmpeg\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="ffmpeg\ffmpeg.exe">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ffmpeg\ffprobe.exe">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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