From 634b95cf2cdef89f63a1be8712c2853a4ad6a7ce Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Mon, 2 Dec 2024 13:51:08 +0000 Subject: [PATCH] Fix pyav 14 error --- torchvision/io/video.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/torchvision/io/video.py b/torchvision/io/video.py index 9f768ed555d..d81b846c12f 100644 --- a/torchvision/io/video.py +++ b/torchvision/io/video.py @@ -155,7 +155,13 @@ def write_video( for img in video_array: frame = av.VideoFrame.from_ndarray(img, format="rgb24") - frame.pict_type = "NONE" + try: + frame.pict_type = "NONE" + except TypeError: + from av.video.frame import PictureType # noqa + + frame.pict_type = PictureType.NONE + for packet in stream.encode(frame): container.mux(packet)