Skip to content

Replace aom-av1 with svt-av1 for saving webm videos, use preset 6 + yuv420p10le pixel format #7736

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

Merged
merged 2 commits into from
Apr 22, 2025

Conversation

alexheretic
Copy link
Contributor

@alexheretic alexheretic commented Apr 22, 2025

This PR adds support for saving .webm outputs using codec svt-av1 and adds an options for using yuv420p10le pixel format switches aom-av1 codec for svt-av1 + yuv420p10le pixel format.

svt-av1 is significantly faster at encoding compared to libaom-av1 and yuv420p10le provides higher quality av1 output without size increase.

Note: av added support for libsvtav1 in v14.1.0, the requirements.txt are upped to reflect this.

Comparison

before (5d0d4ee)

Took 407s to save an 81 frame wan webm using libaom-av1, crf 10.

1.8MB, VMAF 96.9885 vs an animated png output.

pr code with svt-av1 & yuv420p10le selected

Took 1s with libsvtav1 (preset 6, crf 10).

2.3MB, VMAF 97.23115 (note pixel format provides better quality vs aom at yuv420)

preset time & quality

I've set preset 6 for svt-av1, would be straightforward to make this configurable (perhaps later).

  • preset 1: 19.46s, VMAF 97.43995
  • preset 3: 3.88s, VMAF 97.39643
  • preset 6: 0.95s, VMAF 97.23115
  • preset 8: 0.67s, VMAF 96.918396

vs webp

Result is ~2.3MB vs ~6MB .webp using slowest/quality:90, webp also having visibly lower quality.

Implementation notes

I tried to make this non-breaking so any existing usage of av1 will continue to use aom-av1 + yuv420. However, I would recommend always using svt-av1 and yuv420p10le for any CPU-encoding scenario (which seem best for short videos like this as they are better quality than gpu encoding). So perhaps the aom-av1 option should be phased out or somehow discouraged in future. Maybe renamed "aom-av1 (slow)" or something?

@comfyanonymous
Copy link
Owner

You can just switch the "av1" to use svt, I don't think many people are currently using it because of how slow it is. As long as quality is the same or better it's good.

@alexheretic
Copy link
Contributor Author

You can just switch the "av1" to use svt, I don't think many people are currently using it because of how slow it is. As long as quality is the same or better it's good.

Technically aom-av1 produces a little better quality, but it's so much slower that it isn't ever worth it for mortals. But with the pixel format switch we do actually get both 400x faster and better quality (though very slightly larger files, still smaller than the alternatives).

Ok so you'd prefer I keep the interface unchanged and just switch out for svt-av1 + yuv420p10le under the hood?

This might break people how git pull without pip-installing, as they'll perhaps have outdated av. Is that ok? Or should we put in a warning?

Use yuv420p10le for av1
@alexheretic alexheretic changed the title Add support for saving svt-av1 webm videos & yuv420p10le pixel format Replace aom-av1 with svt-av1 for saving webm videos, use preset 6 + yuv420p10le pixel format Apr 22, 2025
@alexheretic
Copy link
Contributor Author

I've updated the approach following your suggestion.

@comfyanonymous
Copy link
Owner

14.1.0 is older than the time the dependency was introduced in ComfyUI so that part is fine. Just to make sure do you know if yuv420p10le compatible with every av1 decoder?

@alexheretic
Copy link
Contributor Author

Just to make sure do you know if yuv420p10le compatible with every av1 decoder?

I don't 100% know. I've never had an issue with it, I think it's part of the av1 spec but I'm not 100% sure. So it's possible that some decoders somewhere could have issue with it. I can add it back as optional if you prefer?

@comfyanonymous comfyanonymous merged commit 92cdc69 into comfyanonymous:master Apr 22, 2025
5 checks passed
@alexheretic alexheretic deleted the svt-av1-webm branch April 22, 2025 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants