From 68bd25dfe3a4286dbc29d8c4d909d84fde86f34c Mon Sep 17 00:00:00 2001 From: anna-charlotte Date: Fri, 21 Oct 2022 15:18:57 +0200 Subject: [PATCH 1/2] feat: add args to load_uri_to_video_tensor From 52dc45ec40bbfd576de76ff46a5c7d0cc7c13efc Mon Sep 17 00:00:00 2001 From: anna-charlotte Date: Mon, 24 Oct 2022 08:54:42 +0200 Subject: [PATCH 2/2] feat: add kwargs to load_uri_to_video_tensor --- docarray/document/mixins/video.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docarray/document/mixins/video.py b/docarray/document/mixins/video.py index e4e692f5aa6..47dadb20a26 100644 --- a/docarray/document/mixins/video.py +++ b/docarray/document/mixins/video.py @@ -97,15 +97,19 @@ def generator_from_webcam( if show_window: cv2.destroyWindow(window_title) - def load_uri_to_video_tensor(self: 'T', only_keyframes: bool = False) -> 'T': + def load_uri_to_video_tensor( + self: 'T', only_keyframes: bool = False, **kwargs + ) -> 'T': """Convert a :attr:`.uri` to a video ndarray :attr:`.tensor`. :param only_keyframes: only keep the keyframes in the video + :param kwargs: supports all keyword arguments that are being supported by av.open() as + described in: https://pyav.org/docs/stable/api/_globals.html?highlight=open#av.open :return: Document itself after processed """ import av - with av.open(self.uri) as container: + with av.open(self.uri, **kwargs) as container: if only_keyframes: stream = container.streams.video[0] stream.codec_context.skip_frame = 'NONKEY'