Load a video from the given file path. Args: video_path (str): The path to the image file. Returns: Video: The loaded video.
(self, video_path: str)
| 871 | return None |
| 872 | |
| 873 | def load_video(self, video_path: str): |
| 874 | """ |
| 875 | Load a video from the given file path. |
| 876 | |
| 877 | Args: |
| 878 | video_path (str): The path to the image file. |
| 879 | |
| 880 | Returns: |
| 881 | Video: The loaded video. |
| 882 | """ |
| 883 | try: |
| 884 | timestamp = str(int(time.time() * 1000)) # Generate timestamp |
| 885 | p = os.path.join(tempfile.gettempdir(), f"vl-{timestamp}.data") |
| 886 | with open(p, "wb") as f: |
| 887 | f.write(base64.b64decode(video_path)) |
| 888 | video = VideoAsset(name=p).np_ndarrays |
| 889 | os.remove(p) |
| 890 | return video |
| 891 | except Exception as e: |
| 892 | print(f"Error loading video {video_path}: {e}", file=sys.stderr) |
| 893 | return None |
| 894 | |
| 895 | async def serve(address): |
| 896 | # Start asyncio gRPC server |