n00mkrad / nmkoder

Media encoding, muxing, analysis toolkit for Windows
GNU General Public License v3.0
427 stars 21 forks source link

Fix Target VMAF svt-av1 crf range error #44

Closed Werve closed 1 year ago

Werve commented 1 year ago

If I understand it right encQualModeBox.SelectedIndex should be about the UI of the QuickConvert tab not Av1An. So I modified it, and now finally the encoding with svt-av1 also updated, works. https://github.com/n00mkrad/nmkoder/issues/36

Werve commented 1 year ago

And according to this https://github.com/master-of-zen/Av1an/blob/master/docs/TargetQuality.md seems it is not needed the --crf arg using Target VMAF so that allows faster encoding and smaller output filesize.

n00mkrad commented 1 year ago

Good job on figuring out why it wasn't working...

But I'm gonna fix the horrible code layout in VideoEncodersBin.cs.

Tons of copy-pasted stuff when you could've used conditions inside interpolated strings.

n00mkrad commented 1 year ago

Though a lot of this encoder shit needs refactoring later, the inheritance based classes were not a good idea

n00mkrad commented 1 year ago

For example, I cleaned up this:

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}");
}

to this:

return new CodecArgs($" -e aom -v \" {(!vmaf ? $"--end-usage=q --cq-level={q}" : "")} --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}");
n00mkrad commented 1 year ago

But again the whole thing could need some refactoring, these args would be prettier in a List or Dictionary...

Werve commented 1 year ago

For example, I cleaned up this:

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}");
}

to this:

return new CodecArgs($" -e aom -v \" {(!vmaf ? $"--end-usage=q --cq-level={q}" : "")} --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}");

Yes it is much better, actually I have always proceeded in a more schematic way. Thank you for sharing that.

However, I noticed that although the encoding now completes correctly the final video file still seems to have the same VMAF quality as if it had been encoded with --crf ignoring --target-vamf . Maybe it is a problem with av1an, I am testing.

Werve commented 1 year ago

I confirm the latest av1an ignore the--target-vmaf arg. The 0.4.0 release version works. https://github.com/master-of-zen/Av1an/issues/719