add qsv av1 encoder (#2471)
This commit is contained in:
+1
-1
@@ -60,7 +60,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Allow HEVC playback in channel preview
|
||||
- This is restricted to compatible browsers
|
||||
- Preview button will be red when preview is disabled due to browser incompatibility
|
||||
- Add AV1 encoding support with NVIDIA and VAAPI acceleration
|
||||
- Add AV1 encoding support with NVIDIA, VAAPI and QSV acceleration
|
||||
- This also requires `HLS Segmenter (fmp4)`
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -57,7 +57,8 @@ public class
|
||||
? FFmpegProfileBitDepth.EightBit
|
||||
: update.BitDepth;
|
||||
|
||||
if (p.HardwareAcceleration is not HardwareAccelerationKind.Nvenc &&
|
||||
if (p.HardwareAcceleration is not (HardwareAccelerationKind.Nvenc or HardwareAccelerationKind.Vaapi
|
||||
or HardwareAccelerationKind.Qsv) &&
|
||||
p.VideoFormat is FFmpegProfileVideoFormat.Av1)
|
||||
{
|
||||
p.VideoFormat = FFmpegProfileVideoFormat.Hevc;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using ErsatzTV.FFmpeg.Format;
|
||||
|
||||
namespace ErsatzTV.FFmpeg.Encoder.Qsv;
|
||||
|
||||
public class EncoderAv1Qsv : EncoderBase
|
||||
{
|
||||
public override string Name => "av1_qsv";
|
||||
public override StreamKind Kind => StreamKind.Video;
|
||||
|
||||
public override string[] OutputOptions => ["-c:v", Name, "-low_power", "0", "-look_ahead", "0"];
|
||||
|
||||
public override FrameState NextState(FrameState currentState) => currentState with
|
||||
{
|
||||
VideoFormat = VideoFormat.Av1,
|
||||
FrameDataLocation = FrameDataLocation.Hardware
|
||||
};
|
||||
}
|
||||
@@ -321,8 +321,6 @@ public class NvidiaPipelineBuilder : SoftwarePipelineBuilder
|
||||
new EncoderH264Nvenc(desiredState.VideoProfile, desiredState.VideoPreset),
|
||||
|
||||
(HardwareAccelerationMode.Nvenc, VideoFormat.Av1) => new EncoderAv1Nvenc(),
|
||||
(HardwareAccelerationMode.None, VideoFormat.Av1) => throw new NotSupportedException(
|
||||
"AV1 software encoding is not supported"),
|
||||
|
||||
// don't pass NVENC profile down to libx264
|
||||
(_, _) => GetSoftwareEncoder(
|
||||
|
||||
@@ -630,6 +630,8 @@ public abstract class PipelineBuilderBase : IPipelineBuilder
|
||||
VideoFormat.H264 => new EncoderLibx264(desiredState.VideoProfile, desiredState.VideoPreset),
|
||||
VideoFormat.Mpeg2Video => new EncoderMpeg2Video(),
|
||||
|
||||
VideoFormat.Av1 => throw new NotSupportedException("AV1 software encoding is not supported"),
|
||||
|
||||
VideoFormat.Copy => new EncoderCopyVideo(),
|
||||
VideoFormat.Undetermined => new EncoderImplicitVideo(),
|
||||
|
||||
|
||||
@@ -77,6 +77,11 @@ public class QsvPipelineBuilder : SoftwarePipelineBuilder
|
||||
encodeCapability = FFmpegCapability.Software;
|
||||
}
|
||||
|
||||
if (desiredState.VideoFormat is VideoFormat.Av1 && ffmpegState.OutputFormat is not OutputFormatKind.HlsMp4)
|
||||
{
|
||||
throw new NotSupportedException("AV1 output is only supported with HLS Segmenter (fmp4)");
|
||||
}
|
||||
|
||||
bool isHevcOrH264 = videoStream.Codec is /*VideoFormat.Hevc or*/ VideoFormat.H264;
|
||||
bool is10Bit = videoStream.PixelFormat.Map(pf => pf.BitDepth).IfNone(8) == 10;
|
||||
|
||||
@@ -229,6 +234,7 @@ public class QsvPipelineBuilder : SoftwarePipelineBuilder
|
||||
Option<IEncoder> maybeEncoder =
|
||||
(ffmpegState.EncoderHardwareAccelerationMode, desiredState.VideoFormat) switch
|
||||
{
|
||||
(HardwareAccelerationMode.Qsv, VideoFormat.Av1) => new EncoderAv1Qsv(),
|
||||
(HardwareAccelerationMode.Qsv, VideoFormat.Hevc) => new EncoderHevcQsv(desiredState.VideoPreset),
|
||||
(HardwareAccelerationMode.Qsv, VideoFormat.H264) => new EncoderH264Qsv(
|
||||
desiredState.VideoProfile,
|
||||
|
||||
@@ -256,9 +256,6 @@ public class VaapiPipelineBuilder : SoftwarePipelineBuilder
|
||||
(HardwareAccelerationMode.Vaapi, VideoFormat.Mpeg2Video) =>
|
||||
new EncoderMpeg2Vaapi(rateControlMode),
|
||||
|
||||
(HardwareAccelerationMode.None, VideoFormat.Av1) => throw new NotSupportedException(
|
||||
"AV1 software encoding is not supported"),
|
||||
|
||||
(_, _) => GetSoftwareEncoder(ffmpegState, currentState, desiredState)
|
||||
};
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.H264">h264</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.Hevc">hevc</MudSelectItem>
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.Mpeg2Video">mpeg-2</MudSelectItem>
|
||||
@if (_model.HardwareAcceleration is (HardwareAccelerationKind.Nvenc or HardwareAccelerationKind.Vaapi))
|
||||
@if (_model.HardwareAcceleration is (HardwareAccelerationKind.Nvenc or HardwareAccelerationKind.Vaapi or HardwareAccelerationKind.Qsv))
|
||||
{
|
||||
<MudSelectItem Value="@FFmpegProfileVideoFormat.Av1">av1</MudSelectItem>
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ public class FFmpegProfileEditViewModelValidator : AbstractValidator<FFmpegProfi
|
||||
[
|
||||
FFmpegProfileVideoFormat.H264,
|
||||
FFmpegProfileVideoFormat.Hevc,
|
||||
FFmpegProfileVideoFormat.Mpeg2Video
|
||||
FFmpegProfileVideoFormat.Mpeg2Video,
|
||||
FFmpegProfileVideoFormat.Av1
|
||||
];
|
||||
|
||||
private static readonly List<FFmpegProfileVideoFormat> NvencFormats =
|
||||
|
||||
Reference in New Issue
Block a user