Skip to content

Commit 86d0a4c

Browse files
committed
Av1an: Automatic HDR/color space args for x265
1 parent 152fa70 commit 86d0a4c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile me
3434
string pixFmt = encArgs.ContainsKey("pixFmt") ? encArgs["pixFmt"] : ColorFormats[ColorFormatDefault];
3535
string thr = encArgs.ContainsKey("threads") ? encArgs["threads"] : "0";
3636
string cust = encArgs.ContainsKey("custom") ? encArgs["custom"] : "";
37-
return new CodecArgs($" -e x265 --force -v \" --crf {q} --preset {preset} --keyint {g} --frame-threads {thr} {cust} \" --pix-format {pixFmt}");
37+
string colors = "";
38+
39+
if (mediaFile != null && mediaFile.ColorData != null)
40+
{
41+
string range = mediaFile.ColorData.ColorRange == 2 ? "full" : "limited"; // x265 range is "limited" (tv) and "full", not 0 (unspecified), 1 (tv), 2 (full) like in VideoColorData
42+
colors = $"--colorprim {mediaFile.ColorData.ColorPrimaries} --transfer {mediaFile.ColorData.ColorTransfer} --colormatrix {mediaFile.ColorData.ColorMatrixCoeffs} --range {range}";
43+
}
44+
45+
return new CodecArgs($" -e x265 --force -v \" --crf {q} --preset {preset} --keyint {g} --frame-threads {thr} {colors} {cust} \" --pix-format {pixFmt}");
3846
}
3947
}
4048
}

ff-utils-winforms/UI/Tasks/Av1an.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public static async Task Run(bool resume = false, string overrideTempDir = "", s
6767
{
6868
if (string.IsNullOrWhiteSpace(overrideArgs))
6969
{
70+
Logger.Log($"Preparing encoding arguments...");
7071
CodecUtils.Av1anCodec vCodec = GetCurrentCodecV();
7172
CodecUtils.AudioCodec aCodec = GetCurrentCodecA();
7273
bool vmaf = IsUsingVmaf();

0 commit comments

Comments
 (0)