Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Target VMAF svt-av1 crf range error #44

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions ff-utils-winforms/Data/Codecs/Video/VideoEncodersBin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,23 @@ public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile me
if (mediaFile.ColorData.ColorPrimaries == 9)
colors += " --deltaq-mode=5 --enable-chroma-deltaq=1";
}

return new CodecArgs($" -e aom -v \" " +

if (vmaf)
{
return new CodecArgs($" -e aom -v \" " +
$"--cpu-used={preset} " +
$"--disable-kf --kf-min-dist=12 --kf-max-dist={g} " +
$"--enable-dnl-denoising={denoise} --denoise-noise-level={grain} " +
$"{colors} --threads={thr} {tiles} {adv} {cust} \" --pix-format {pixFmt}");
}
else
{
return new CodecArgs($" -e aom -v \" " +
$"--end-usage=q --cpu-used={preset} --cq-level={q} " +
$"--disable-kf --kf-min-dist=12 --kf-max-dist={g} " +
$"--enable-dnl-denoising={denoise} --denoise-noise-level={grain} " +
$"{colors} --threads={thr} {tiles} {adv} {cust} \" --pix-format {pixFmt}");
}
}
}

Expand Down Expand Up @@ -107,8 +118,11 @@ public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile me
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
colors = $"--color-primaries {mediaFile.ColorData.ColorPrimaries} --transfer-characteristics {mediaFile.ColorData.ColorTransfer} --matrix-coefficients {mediaFile.ColorData.ColorMatrixCoeffs} --color-range {range}";
}

return new CodecArgs($" -e svt-av1 --force -v \" --preset {preset} --crf {q} --keyint {g} --lp {thr} --film-grain {grain} --film-grain-denoise {denoise} {colors} {tiles} {adv} {cust} \" --pix-format {pixFmt}");

if (vmaf)
return new CodecArgs($" -e svt-av1 --force -v \" --preset {preset} --keyint {g} --lp {thr} --film-grain {grain} --film-grain-denoise {denoise} {colors} {tiles} {adv} {cust} \" --pix-format {pixFmt}");
else
return new CodecArgs($" -e svt-av1 --force -v \" --preset {preset} --crf {q} --keyint {g} --lp {thr} --film-grain {grain} --film-grain-denoise {denoise} {colors} {tiles} {adv} {cust} \" --pix-format {pixFmt}");
}
}

Expand Down Expand Up @@ -147,10 +161,19 @@ public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile me
int p = b > 8 ? (is420 ? 2 : 3) : (is420 ? 0 : 1); // Profile 0: 4:2:0 8-bit | Profile 1: 4:2:2/4:4:4 8-bit | Profile 2: 4:2:0 10/12-bit | Profile 3: 4:2:2/4:4:4 10/12-bit
string tiles = mediaFile.VideoStreams.Count > 0 ? CodecUtils.GetTilingArgs(mediaFile.VideoStreams.FirstOrDefault().Resolution, "--tile-columns=", "--tile-rows=") : "";
string cust = encArgs.ContainsKey("custom") ? encArgs["custom"] : "";

return new CodecArgs($" -e vpx --force -v \" --codec=vp9 --profile={p} --bit-depth={b} " +

if (vmaf)
{
return new CodecArgs($" -e vpx --force -v \" --codec=vp9 --profile={p} --bit-depth={b} " +
$"--cpu-used={preset} " +
$"--kf-max-dist={g} --threads={thr} --row-mt=1 {tiles} {cust} \" --pix-format {pixFmt}");
}
else
{
return new CodecArgs($" -e vpx --force -v \" --codec=vp9 --profile={p} --bit-depth={b} " +
$"--end-usage=q --cpu-used={preset} --cq-level={q} " +
$"--kf-max-dist={g} --threads={thr} --row-mt=1 {tiles} {cust} \" --pix-format {pixFmt}");
}
}
}

Expand Down Expand Up @@ -193,8 +216,11 @@ public CodecArgs GetArgs(Dictionary<string, string> encArgs = null, MediaFile me
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
colors = $"--colorprim {mediaFile.ColorData.ColorPrimaries} --transfer {mediaFile.ColorData.ColorTransfer} --colormatrix {mediaFile.ColorData.ColorMatrixCoeffs} --range {range}";
}

return new CodecArgs($" -e x265 --force -v \" --crf {q} --preset {preset} --keyint {g} --frame-threads {thr} --output-depth {bitDepth} {colors} {adv} {cust} \" --pix-format {pixFmt}");

if (vmaf)
return new CodecArgs($" -e x265 --force -v \" --preset {preset} --keyint {g} --frame-threads {thr} --output-depth {bitDepth} {colors} {adv} {cust} \" --pix-format {pixFmt}");
else
return new CodecArgs($" -e x265 --force -v \" --crf {q} --preset {preset} --keyint {g} --frame-threads {thr} --output-depth {bitDepth} {colors} {adv} {cust} \" --pix-format {pixFmt}");
}
}
}
2 changes: 1 addition & 1 deletion ff-utils-winforms/UI/Tasks/Av1anUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public static CodecUtils.AudioCodec GetCurrentCodecA()
public static Dictionary<string, string> GetVideoArgsFromUi()
{
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("qMode", form.encQualModeBox.SelectedIndex.ToString());
dict.Add("qMode", form.av1anQualModeBox.SelectedIndex.ToString());
dict.Add("q", form.av1anQualityUpDown.Value.ToString());
dict.Add("preset", form.av1anPresetBox.Text.ToLower());
dict.Add("pixFmt", PixFmtUtils.GetFormat(CodecUtils.GetCodec((CodecUtils.Av1anCodec)Program.mainForm.av1anCodecBox.SelectedIndex).ColorFormats[Program.mainForm.av1anColorsBox.SelectedIndex]).Name);
Expand Down