@@ -31,7 +31,10 @@ def video_info(obj: ArrayLike) -> Tuple[Tuple[int, int, int], str]:
3131 :return: shape (height,width,components) and data type str
3232 :rtype: Tuple[Tuple[int, int, int], str]
3333 """
34- return obj .shape [- 3 :] if obj .ndim != 2 else [* obj .shape , 1 ], obj .dtype .str
34+ try :
35+ return obj .shape [- 3 :] if obj .ndim != 2 else [* obj .shape , 1 ], obj .dtype .str
36+ except :
37+ return None
3538
3639
3740@hookimpl
@@ -43,7 +46,10 @@ def audio_info(obj: ArrayLike) -> Tuple[int, str]:
4346 :return: number of channels and sample data type in data type str
4447 :rtype: Tuple[Tuple[int], str]
4548 """
46- return obj .shape [- 1 :] if obj .ndim > 1 else [1 ], obj .dtype .str
49+ try :
50+ return obj .shape [- 1 :] if obj .ndim > 1 else [1 ], obj .dtype .str
51+ except :
52+ return None
4753
4854
4955@hookimpl
@@ -56,7 +62,10 @@ def video_bytes(obj: ArrayLike) -> memoryview:
5662 :rtype: memoryview
5763 """
5864
59- return memoryview (np .ascontiguousarray (obj ))
65+ try :
66+ return memoryview (np .ascontiguousarray (obj ))
67+ except :
68+ return None
6069
6170
6271@hookimpl
@@ -69,7 +78,10 @@ def audio_bytes(obj: ArrayLike) -> memoryview:
6978 :rtype: memoryview
7079 """
7180
72- return memoryview (np .ascontiguousarray (obj ))
81+ try :
82+ return memoryview (np .ascontiguousarray (obj ))
83+ except :
84+ return None
7385
7486
7587@hookimpl
@@ -90,9 +102,11 @@ def bytes_to_video(
90102 :rtype: ArrayLike
91103 """
92104
93- x = np .frombuffer (b , dtype ).reshape (- 1 , * shape )
94- return x .squeeze () if squeeze else x
95-
105+ try :
106+ x = np .frombuffer (b , dtype ).reshape (- 1 , * shape )
107+ return x .squeeze () if squeeze else x
108+ except :
109+ return None
96110
97111@hookimpl
98112def bytes_to_audio (b : bytes , dtype : str , shape : Tuple [int ], squeeze : bool ) -> ArrayLike :
@@ -110,5 +124,9 @@ def bytes_to_audio(b: bytes, dtype: str, shape: Tuple[int], squeeze: bool) -> Ar
110124 :rtype: ArrayLike
111125 """
112126
113- x = np .frombuffer (b , dtype ).reshape (- 1 , * shape )
114- return x .squeeze () if squeeze else x
127+ try :
128+ x = np .frombuffer (b , dtype ).reshape (- 1 , * shape )
129+ return x .squeeze () if squeeze else x
130+ except :
131+ return None
132+
0 commit comments