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.
51 lines
1.4 KiB
51 lines
1.4 KiB
using ErsatzTV.FFmpeg.Capabilities; |
|
using ErsatzTV.FFmpeg.Format; |
|
|
|
namespace ErsatzTV.FFmpeg.Encoder.Nvenc; |
|
|
|
public class EncoderHevcNvenc : EncoderBase |
|
{ |
|
private readonly Option<string> _maybeVideoPreset; |
|
private readonly bool _bFrames; |
|
|
|
public EncoderHevcNvenc(IHardwareCapabilities hardwareCapabilities, Option<string> maybeVideoPreset) |
|
{ |
|
_maybeVideoPreset = maybeVideoPreset; |
|
if (hardwareCapabilities is NvidiaHardwareCapabilities nvidia) |
|
{ |
|
_bFrames = nvidia.HevcBFrames; |
|
} |
|
} |
|
|
|
public override string Name => "hevc_nvenc"; |
|
public override StreamKind Kind => StreamKind.Video; |
|
|
|
public override string[] OutputOptions |
|
{ |
|
get |
|
{ |
|
var result = new List<string> |
|
{ |
|
"-c:v", "hevc_nvenc", |
|
"-tag:v", "hvc1", |
|
"-b_ref_mode", _bFrames ? "1" : "0" |
|
}; |
|
|
|
foreach (string videoPreset in _maybeVideoPreset) |
|
{ |
|
if (!string.IsNullOrWhiteSpace(videoPreset)) |
|
{ |
|
result.Add("-preset:v"); |
|
result.Add(videoPreset); |
|
} |
|
} |
|
|
|
return result.ToArray(); |
|
} |
|
} |
|
|
|
public override FrameState NextState(FrameState currentState) => currentState with |
|
{ |
|
VideoFormat = VideoFormat.Hevc |
|
}; |
|
}
|
|
|