Skip to content

Commit 1b382d5

Browse files
committed
Disable tiling for SVT (is somehow slower than 1 tile), cap gop size to 255 with VBR
1 parent ef1d478 commit 1b382d5

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

ff-utils-winforms/Data/CodecUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ public static IEncoder GetCodec(SubtitleCodec c)
7474
return null;
7575
}
7676

77-
public static string GetKeyIntArg(MediaFile mediaFile, int intervalSeconds, string arg = "-g ")
77+
public static string GetKeyIntArg(MediaFile mediaFile, int intervalSeconds, string arg = "-g ", int max = 480)
7878
{
7979
if (mediaFile == null || mediaFile.VideoStreams.Count < 1)
8080
return "";
8181

8282
int keyInt = ((float)(mediaFile?.VideoStreams.FirstOrDefault().Rate.GetFloat() * intervalSeconds)).RoundToInt();
83-
return $"{arg}{keyInt.Clamp(20, 480)}";
83+
return $"{arg}{keyInt.Clamp(12, max)}";
8484
}
8585

8686
public static string GetAudioArgsForEachStream(MediaFile mf, int baseBitrate, int overrideChannels, List<string> extraArgs = null)

ff-utils-winforms/Data/Codecs/Video/LibSvtAv1.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class LibSvtAv1 : IEncoder
3030
public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile mediaFile = null, Pass pass = Pass.OneOfOne)
3131
{
3232
bool vbr = encArgs.ContainsKey("qMode") && (UI.Tasks.QuickConvert.QualityMode)encArgs["qMode"].GetInt() != UI.Tasks.QuickConvert.QualityMode.Crf;
33-
if (vbr && pass == Pass.TwoOfTwo) Logger.Log($"WARNING: The 2-Pass implementation of SVT-AV1 is experimental. It might crash or produce inaccurate results.");
33+
if (vbr && pass == Pass.OneOfTwo) Logger.Log($"WARNING: The 2-Pass implementation of SVT-AV1 is experimental. It might crash or produce inaccurate results.");
3434
string q = encArgs.ContainsKey("q") ? encArgs["q"] : QDefault.ToString();
3535
string preset = encArgs.ContainsKey("preset") ? encArgs["preset"] : Presets[PresetDefault];
3636
string pixFmt = encArgs.ContainsKey("pixFmt") ? encArgs["pixFmt"] : ColorFormats[ColorFormatDefault];
3737
string rc = vbr ? $"-rc vbr -b:v {(encArgs.ContainsKey("bitrate") ? encArgs["bitrate"] : "0")}k" : $"-qp {q}";
38-
string g = CodecUtils.GetKeyIntArg(mediaFile, Config.GetInt(Config.Key.defaultKeyIntSecs));
38+
string g = CodecUtils.GetKeyIntArg(mediaFile, Config.GetInt(Config.Key.defaultKeyIntSecs), "-g ", vbr ? 255 : 480); // SVT can't do GOP size >255 in VBR mode
3939
string p = pass == Pass.OneOfOne ? "" : (pass == Pass.OneOfTwo ? "-pass 1" : "-pass 2");
40-
string tiles = CodecUtils.GetTilingArgs(mediaFile.VideoStreams.FirstOrDefault().Resolution, "-tile_rows ", "-tile_columns ");
40+
string tiles = ""; // TEMP DISABLED AS IT SEEMS TO SLOW THINGS DOWN // CodecUtils.GetTilingArgs(mediaFile.VideoStreams.FirstOrDefault().Resolution, "-tile_rows ", "-tile_columns ");
4141
string cust = encArgs.ContainsKey("custom") ? encArgs["custom"] : "";
4242
return new CodecArgs($"-c:v libsvtav1 {p} {rc} -preset {preset} {g} {tiles} -pix_fmt {pixFmt} {cust}");
4343
}

ff-utils-winforms/Data/Codecs/Video/SvtAv1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile me
3737
string pixFmt = encArgs.ContainsKey("pixFmt") ? encArgs["pixFmt"] : ColorFormats[ColorFormatDefault];
3838
string grain = encArgs.ContainsKey("grainSynthStrength") ? encArgs["grainSynthStrength"] : "0";
3939
string thr = encArgs.ContainsKey("threads") ? encArgs["threads"] : "0";
40-
string tiles = CodecUtils.GetTilingArgs(mediaFile.VideoStreams.FirstOrDefault().Resolution, "--tile-rows ", "--tile-columns ");
40+
string tiles = ""; // TEMP DISABLED AS IT SEEMS TO SLOW THINGS DOWN // = CodecUtils.GetTilingArgs(mediaFile.VideoStreams.FirstOrDefault().Resolution, "--tile-rows ", "--tile-columns ");
4141
string cust = encArgs.ContainsKey("custom") ? encArgs["custom"] : "";
4242
return new CodecArgs($" -e svt-av1 --force -v \" --preset {preset} --crf {q} --keyint {g} --lp {thr} --film-grain {grain} {tiles} {cust} \" --pix-format {pixFmt}");
4343
}

0 commit comments

Comments
 (0)