(video_frames: list[np.ndarray], output_video_path: str = None)
| 1046 | |
| 1047 | |
| 1048 | def export_to_video(video_frames: list[np.ndarray], output_video_path: str = None) -> str: |
| 1049 | if is_opencv_available(): |
| 1050 | import cv2 |
| 1051 | else: |
| 1052 | raise ImportError(BACKENDS_MAPPING["opencv"][1].format("export_to_video")) |
| 1053 | if output_video_path is None: |
| 1054 | output_video_path = tempfile.NamedTemporaryFile(suffix=".mp4").name |
| 1055 | |
| 1056 | fourcc = cv2.VideoWriter_fourcc(*"mp4v") |
| 1057 | h, w, c = video_frames[0].shape |
| 1058 | video_writer = cv2.VideoWriter(output_video_path, fourcc, fps=8, frameSize=(w, h)) |
| 1059 | for i in range(len(video_frames)): |
| 1060 | img = cv2.cvtColor(video_frames[i], cv2.COLOR_RGB2BGR) |
| 1061 | video_writer.write(img) |
| 1062 | return output_video_path |
| 1063 | |
| 1064 | |
| 1065 | def load_hf_numpy(path) -> np.ndarray: |
no test coverage detected
searching dependent graphs…