diff --git a/av/video/frame.py b/av/video/frame.py index 970ecc4b8..0d60fd8e9 100644 --- a/av/video/frame.py +++ b/av/video/frame.py @@ -610,16 +610,22 @@ def to_ndarray(self, channel_last=False, **kwargs): f"Conversion to numpy array with format `{frame.format.name}` is not yet supported" ) - @staticmethod - def from_image(img): + def set_image(self, img): """ - Construct a frame from a ``PIL.Image``. + Update content from a ``PIL.Image``. """ if img.mode != "RGB": img = img.convert("RGB") + copy_array_to_plane(img, self.planes[0], 3) + + @staticmethod + def from_image(img): + """ + Construct a frame from a ``PIL.Image``. + """ frame: VideoFrame = VideoFrame(img.size[0], img.size[1], "rgb24") - copy_array_to_plane(img, frame.planes[0], 3) + frame.set_image(img) return frame