diff --git a/python/videoreader/__init__.py b/python/videoreader/__init__.py index b8585f9..a162623 100755 --- a/python/videoreader/__init__.py +++ b/python/videoreader/__init__.py @@ -127,7 +127,9 @@ def seek_get_img(self, seek_idx: int) -> T | None: def set(self, arguments: list[str]) -> None: argv_keepalive = [ffi.new("char[]", arg.encode()) for arg in arguments] - if backend.videoreader_set(self._handler, argv_keepalive, len(argv_keepalive)): + if backend.videoreader_set( + self._handler, argv_keepalive, len(argv_keepalive) + ): raise_error() @@ -187,7 +189,9 @@ def videoreader_n_frames(uri: str) -> int: Get number of frames in a file """ handler = ffi.new("struct videoreader **") - backend.videoreader_create(handler, uri.encode("utf-8"), [], 0, ffi.NULL, ffi.NULL) + backend.videoreader_create( + handler, uri.encode("utf-8"), [], 0, ffi.NULL, ffi.NULL + ) n_frames = ffi.new("uint64_t *") backend.videoreader_size(handler[0], n_frames) backend.videoreader_delete(handler[0]) diff --git a/python/videoreader/__main__.py b/python/videoreader/__main__.py index 7acbe1d..044d376 100644 --- a/python/videoreader/__main__.py +++ b/python/videoreader/__main__.py @@ -5,7 +5,9 @@ def main(): parser = ArgumentParser() - default = Path(__file__).parents[2] / "test" / "big_buck_bunny_480p_1mb.mp4" + default = ( + Path(__file__).parents[2] / "test" / "big_buck_bunny_480p_1mb.mp4" + ) parser.add_argument("uri", nargs="?", default=default) parser.add_argument( "--backend", choices=["base", "numpy", "minimg"], default="base" @@ -18,7 +20,9 @@ def main(): case "base": from . import VideoReaderBase as VideoReader - fmt_image = lambda image: f"{image.width}x{image.height}x{image.channels}" + fmt_image = ( + lambda image: f"{image.width}x{image.height}x{image.channels}" + ) case "numpy": from .numpy import VideoReaderNumpy as VideoReader diff --git a/python/videoreader/minimg.py b/python/videoreader/minimg.py index 05e189b..5fd0651 100644 --- a/python/videoreader/minimg.py +++ b/python/videoreader/minimg.py @@ -11,7 +11,9 @@ @ffi.callback("void (VRImage*, void*)") def alloc_callback_numpy(image: ffi.CData, self: ffi.CData) -> None: assert image.scalar_type == 0, f"non uint8 images not yet supported" - img = MinImg.empty(image.width, image.height, image.channels, mintype=TYP_UINT8) + img = MinImg.empty( + image.width, image.height, image.channels, mintype=TYP_UINT8 + ) image.data = img.data image.stride = img.stride address = int(ffi.cast("uintptr_t", image.data)) diff --git a/python/videoreader/numpy.py b/python/videoreader/numpy.py index 60fe74f..89788bd 100644 --- a/python/videoreader/numpy.py +++ b/python/videoreader/numpy.py @@ -12,7 +12,9 @@ def alloc_callback_numpy(image: ffi.CData, self: ffi.CData) -> None: assert image.scalar_type == 0, f"non uint8 images not yet supported" if image.channels == 3: - arr = np.empty((image.height, image.width, image.channels), dtype=np.uint8) + arr = np.empty( + (image.height, image.width, image.channels), dtype=np.uint8 + ) ai = arr.__array_interface__ address = ai["data"][0] assert (