Added SW encoding strategies
This commit is contained in:
@@ -89,7 +89,7 @@ public class EncoderService : BackgroundService, IEncoderService {
|
||||
FileName = Path.Combine(options.FfmpegPath, "ffmpeg.exe"),
|
||||
Arguments = @"-hide_banner -init_hw_device ""list""",
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = true,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
using Process ffmpeg = Process.Start(psi)!;
|
||||
@@ -97,12 +97,21 @@ public class EncoderService : BackgroundService, IEncoderService {
|
||||
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),
|
||||
EncoderType.AV1 => new AV1EncodingStrategy(file, outputPath, job),
|
||||
IEncodingStrategy strategy;
|
||||
|
||||
if(nvenc) strategy= job.RequestedEncoding switch {
|
||||
EncoderType.H264 => new H264NvencEncodingStrategy(file, outputPath, job),
|
||||
EncoderType.HEVC => new HevcNvencEncodingStrategy(file, outputPath, job),
|
||||
EncoderType.AV1 => new AV1NvencEncodingStrategy(file, outputPath, job),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(job), job, null)
|
||||
};
|
||||
else strategy = job.RequestedEncoding switch {
|
||||
EncoderType.H264 => new H264SwEncodingStrategy(file, outputPath, job),
|
||||
EncoderType.HEVC => new HevcSwEncodingStrategy(file, outputPath, job),
|
||||
EncoderType.AV1 => new AV1SwEncodingStrategy(file, outputPath, job),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(job), job, null)
|
||||
};
|
||||
|
||||
bool result = await strategy.ExecuteAsync(cancellationToken, Progress);
|
||||
|
||||
if(result) {
|
||||
|
||||
Reference in New Issue
Block a user