properly implemented svtav1 strategy and added a temporary set of values, same with x265 (cpu)

This commit is contained in:
Samuele Lorefice
2025-12-23 03:58:10 +01:00
parent 2ddcfd2edb
commit f6869e54ac
3 changed files with 182 additions and 47 deletions

View File

@@ -162,11 +162,11 @@ public class AV1SwEncodingStrategy(string inputFilePath, string outputFilePath,
public string OutputFilePath { get; set; } = outputFilePath;
private static readonly Tuple<int, int>[] QPTable = new Tuple<int, int>[] {
new(1280*720, 64),
new(1920*1080, 96),
new(3840*2160, 128),
new(5760*2880, 96), //VR6K
new(8128*4096, 120) //VR8K
new(1280*720, 27),
new(1920*1080, 28),
new(3840*2160, 29),
new(5760*2880, 30), //VR6K
new(8128*4096, 32) //VR8K
}.OrderBy(t => t.Item1).ToArray();
public async Task<bool> ExecuteAsync(CancellationToken cancellationToken, Action<EncodingProgress> onProgress) {
@@ -180,8 +180,11 @@ public class AV1SwEncodingStrategy(string inputFilePath, string outputFilePath,
.OutputToFile(OutputFilePath, true, args => args
.CopyChannel(Channel.Audio)
.CopyChannel(Channel.Subtitle)
.WithVideoCodec(VideoCodec.LibaomAv1)
// TODO: adjust settings for software AV1 encoding
.WithVideoCodec("libsvtav1")
.WithCustomArgument($"-preset 7")
.WithConstantRateFactor(qp)
.WithCustomArgument("-svtav1-params tune=0")
.WithVideoFilters(filterOptions => {if (W > 0 && H > 0) filterOptions.Scale(W, H);})
.WithFastStart()
)
.NotifyOnProgress(progress => onProgress(new() {
@@ -204,11 +207,11 @@ public class HevcSwEncodingStrategy(string inputFilePath, string outputFilePath,
//TODO: needs to be adjusted for software HEVC encoding
private static readonly Tuple<int, int>[] QPTable = new Tuple<int, int>[] {
new(1280*720, 0),
new(1920*1080, 0),
new(3840*2160, 0),
new(5760*2880, 0), //VR6K
new(8128*4096, 0) //VR8K
new(1280*720, 20),
new(1920*1080, 22),
new(3840*2160, 26),
new(5760*2880, 26), //VR6K
new(8128*4096, 28) //VR8K
}.OrderBy(t => t.Item1).ToArray();
public async Task<bool> ExecuteAsync(CancellationToken cancellationToken, Action<EncodingProgress> onProgress) {
@@ -223,10 +226,10 @@ public class HevcSwEncodingStrategy(string inputFilePath, string outputFilePath,
.CopyChannel(Channel.Audio)
.CopyChannel(Channel.Subtitle)
.WithVideoCodec(VideoCodec.LibX265)
.WithArgument(new NvencSpeedPreset(NvencSpeed.p2))
.WithArgument(new NvencTuneArgument(NvencTune.hq))
.WithArgument(new NvencHighBitDepthArgument(true))
.WithArgument(new NvencQPArgument((byte)qp))
.WithSpeedPreset(Speed.Slow)
.WithConstantRateFactor(qp)
.WithCustomArgument("-x265-params profile=main10:high-tier=1:aq-mode=3:psy-rd=1:rc-lookahead=60:bframes=6")
.WithVideoFilters(filterOptions => {if (W > 0 && H > 0) filterOptions.Scale(W, H);})
.WithFastStart()
)
.NotifyOnProgress(progress => onProgress(new() {