Skip to content

Commit 152fa70

Browse files
committed
Av1an: Automatic HDR/color space args for SVT
1 parent 9fc669e commit 152fa70

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile me
3939
string thr = encArgs.ContainsKey("threads") ? encArgs["threads"] : "0";
4040
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"] : "";
42-
return new CodecArgs($" -e svt-av1 --force -v \" --preset {preset} --crf {q} --keyint {g} --lp {thr} --film-grain {grain} {tiles} {cust} \" --pix-format {pixFmt}");
42+
string colors = "";
43+
44+
if (mediaFile != null && mediaFile.ColorData != null)
45+
{
46+
int range = mediaFile.ColorData.ColorRange == 2 ? 1 : 0; // SVT range is 0 (tv) and 1 (full), not 0 (unspecified), 1 (tv), 2 (full) like in VideoColorData
47+
colors = $"--color-primaries {mediaFile.ColorData.ColorPrimaries} --transfer-characteristics {mediaFile.ColorData.ColorTransfer} --matrix-coefficients {mediaFile.ColorData.ColorMatrixCoeffs} --color-range {range}";
48+
}
49+
50+
return new CodecArgs($" -e svt-av1 --force -v \" --preset {preset} --crf {q} --keyint {g} --lp {thr} --film-grain {grain} {colors} {tiles} {cust} \" --pix-format {pixFmt}");
4351
}
4452
}
4553
}

0 commit comments

Comments
 (0)