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

[question] How to get the best quality? #14

Open
megapro17 opened this issue Apr 4, 2020 · 2 comments
Open

[question] How to get the best quality? #14

megapro17 opened this issue Apr 4, 2020 · 2 comments
Labels
question Further information is requested

Comments

@megapro17
Copy link

megapro17 commented Apr 4, 2020

I want to convert old jpg's to this format. After some testing I came to this command
cavif -i 1.png --rate-control q --crf 10 --row-mt --tile-rows 2 --tile-columns 2 --threads 4 -o 1.avif
CRF mode as written in many guides is stands for the most recommended mode. Is it right to this case? When value is 10 I can't spot any difference between original, but size decreased significantly 7,16 MB -> 519 KB. The program is eating 10 GB RAM, is this how it should be? Also, how to disable alpha channel? In photo proprieties I can see color depth is 32 bit, but original was 24.

@megapro17 megapro17 changed the title How to get the best quality? [question] How to get the best quality? Apr 4, 2020
@ledyba-z
Copy link
Contributor

ledyba-z commented Apr 5, 2020

Thank you for using cavif!

cavif -i 1.png --rate-control q --crf 10 --row-mt --tile-rows 2 --tile-columns 2 --threads 4 -o 1.avif

If you really want to achieve best quality at the expense of encoding/decoding speed, I also recommend these options:

  • disabling --row-mt, --tile-rows, and --tile-cols
    • If these options is set, each separeted image are encoded independently. In general, it is expected to be encoded more efficiently if using the information of the whole image.
    • I think you set these options to make encoding or decoding fast.
      But if the quality is improve by these options, please tell me.
  • --cpu-used 0 (default: --cpu-used 1)
    • --cpu-used 0 tells encoder to use more and more computation resources to achieve best quality.
    • However, this is extremely and unbelievably slow. Really.
  • --enable-cdef (default: disabled)
    • CDEF is a kind of post-process filter. It is said CDEF improves subjective image quality.
    • However, this makes decoding time longer and longer. In my environment, it takes 5 times slower to decode.

CRF mode as written in many guides is stands for the most recommended mode.
Is it right to this case?

Yes. To tell you the truth, "--crf 10" is the libaom (underlying library)'s default value:
(We currently use this command to convert image to low bit rate, thus "--crf 32" is cavif's default now. I might change this default value.)

https://github.com/link-u/libaom/blob/d0b3d306aebb5ef6cc89f49f56dd7adaee41f696/av1/av1_cx_iface.c#L173

Anyway, I recommend you to check the quality with some images with your eyes, before encoding tons of images.

When value is 10 I can't spot any difference between original, but size decreased significantly 7,16 MB -> 519 KB.

Great!

The program is eating 10 GB RAM, is this how it should be?

It depends on the image size, however, "10GB" sounds lager than the ordinary image.
Could you tell me the width and height of the image, try disabling --row-mt, --tile-rows, and --tile-cols, and check the eaten RAM again?
If it won't improve, could you give me some sample images to debug?

Here is our example images: https://github.com/link-u/avif-sample-images
We encode and decode daily in Github Actions, a virtual machine with 7GB RAM.

Also, how to disable alpha channel? In photo proprieties I can see color depth is 32 bit, but original was 24.

Alpha is disabled by default (If you want to enable it, you must encode twice).

I think your software uses 32bit RGBA for AVIF currently, to make easy to support AVIF.
davif and SDWebImageAVIFCoder handles (Monochrome/Monochrome+Alpha/RGB/RGBA) images correctly, but it is very confusing work.
Could you tell me what software you use to view encoded avif?

@ledyba-z ledyba-z added the question Further information is requested label Apr 5, 2020
@ledyba-z
Copy link
Contributor

ledyba-z commented Apr 5, 2020

I forgot to introduce this option:

--enable-full-color-range (default: disabled)

AV1 is derived from video codec. In video, we often don't use all 255^3 colors (in historical reason). Instead, 229 * 224 * 224 colors are used (about 70%).

When this flag is enabled, encoder/decoder uses all colors.
This flag makes encoded files a little bigger, but you can get images with better color reproductions.
It might be useful for images with gradients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants