Skip to content

Commit 92cdc69

Browse files
authored
Replace aom-av1 with svt-av1 for saving webm videos, use preset 6 + yuv420p10le pixel format (Comfy-Org#7736)
* Add support for saving svt-av1 webm videos & yuv420p10le pixel format * Replace aom-av1 with svt-av1 Use yuv420p10le for av1
1 parent 2d6805c commit 92cdc69

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

comfy_extras/nodes_video.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ def save_images(self, images, codec, fps, filename_prefix, crf, prompt=None, ext
5050
for x in extra_pnginfo:
5151
container.metadata[x] = json.dumps(extra_pnginfo[x])
5252

53-
codec_map = {"vp9": "libvpx-vp9", "av1": "libaom-av1"}
53+
codec_map = {"vp9": "libvpx-vp9", "av1": "libsvtav1"}
5454
stream = container.add_stream(codec_map[codec], rate=Fraction(round(fps * 1000), 1000))
5555
stream.width = images.shape[-2]
5656
stream.height = images.shape[-3]
57-
stream.pix_fmt = "yuv420p"
57+
stream.pix_fmt = "yuv420p10le" if codec == "av1" else "yuv420p"
5858
stream.bit_rate = 0
5959
stream.options = {'crf': str(crf)}
60+
if codec == "av1":
61+
stream.options["preset"] = "6"
6062

6163
for frame in images:
6264
frame = av.VideoFrame.from_ndarray(torch.clamp(frame[..., :3] * 255, min=0, max=255).to(device=torch.device("cpu"), dtype=torch.uint8).numpy(), format="rgb24")

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ psutil
2222
kornia>=0.7.1
2323
spandrel
2424
soundfile
25-
av
25+
av>=14.1.0

0 commit comments

Comments
 (0)