mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.4 KiB
37 lines
1.4 KiB
using Microsoft.Extensions.Logging; |
|
|
|
namespace ErsatzTV.FFmpeg.Option.HardwareAcceleration; |
|
|
|
public static class AvailableHardwareAccelerationOptions |
|
{ |
|
public static Option<IPipelineStep> ForMode( |
|
HardwareAccelerationMode mode, |
|
Option<string> vaapiDevice, |
|
ILogger logger) => |
|
mode switch |
|
{ |
|
HardwareAccelerationMode.Nvenc => new CudaHardwareAccelerationOption(), |
|
HardwareAccelerationMode.Qsv => new QsvHardwareAccelerationOption(), |
|
HardwareAccelerationMode.Vaapi => GetVaapiAcceleration(vaapiDevice, logger), |
|
HardwareAccelerationMode.VideoToolbox => new VideoToolboxHardwareAccelerationOption(), |
|
HardwareAccelerationMode.None => Option<IPipelineStep>.None, |
|
_ => LogUnknownMode(mode, logger) |
|
}; |
|
|
|
private static Option<IPipelineStep> GetVaapiAcceleration(Option<string> vaapiDevice, ILogger logger) |
|
{ |
|
foreach (string device in vaapiDevice) |
|
{ |
|
return new VaapiHardwareAccelerationOption(device); |
|
} |
|
|
|
logger.LogWarning("VAAPI device name is missing; falling back to software mode"); |
|
return Option<IPipelineStep>.None; |
|
} |
|
|
|
private static Option<IPipelineStep> LogUnknownMode(HardwareAccelerationMode mode, ILogger logger) |
|
{ |
|
logger.LogWarning("Unexpected hardware acceleration mode {AccelMode}; may have playback issues", mode); |
|
return Option<IPipelineStep>.None; |
|
} |
|
}
|
|
|