(video_frames: List[np.ndarray], output_video_path: str = None)
| 502 | |
| 503 | |
| 504 | def export_to_video(video_frames: List[np.ndarray], output_video_path: str = None) -> str: |
| 505 | if is_opencv_available(): |
| 506 | import cv2 |
| 507 | else: |
| 508 | raise ImportError(BACKENDS_MAPPING["opencv"][1].format("export_to_video")) |
| 509 | if output_video_path is None: |
| 510 | output_video_path = tempfile.NamedTemporaryFile(suffix=".mp4").name |
| 511 | |
| 512 | fourcc = cv2.VideoWriter_fourcc(*"mp4v") |
| 513 | h, w, c = video_frames[0].shape |
| 514 | video_writer = cv2.VideoWriter(output_video_path, fourcc, fps=8, frameSize=(w, h)) |
| 515 | for i in range(len(video_frames)): |
| 516 | img = cv2.cvtColor(video_frames[i], cv2.COLOR_RGB2BGR) |
| 517 | video_writer.write(img) |
| 518 | return output_video_path |
| 519 | |
| 520 | |
| 521 | def load_hf_numpy(path) -> np.ndarray: |
nothing calls this directly
no test coverage detected