Skip to content

Commit 26e039b

Browse files
feat: add args to load_uri_to_video_tensor (#663)
1 parent 9a6a390 commit 26e039b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

docarray/document/mixins/video.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,19 @@ def generator_from_webcam(
9797
if show_window:
9898
cv2.destroyWindow(window_title)
9999

100-
def load_uri_to_video_tensor(self: 'T', only_keyframes: bool = False) -> 'T':
100+
def load_uri_to_video_tensor(
101+
self: 'T', only_keyframes: bool = False, **kwargs
102+
) -> 'T':
101103
"""Convert a :attr:`.uri` to a video ndarray :attr:`.tensor`.
102104
103105
:param only_keyframes: only keep the keyframes in the video
106+
:param kwargs: supports all keyword arguments that are being supported by av.open() as
107+
described in: https://pyav.org/docs/stable/api/_globals.html?highlight=open#av.open
104108
:return: Document itself after processed
105109
"""
106110
import av
107111

108-
with av.open(self.uri) as container:
112+
with av.open(self.uri, **kwargs) as container:
109113
if only_keyframes:
110114
stream = container.streams.video[0]
111115
stream.codec_context.skip_frame = 'NONKEY'

0 commit comments

Comments
 (0)