(video_frames: List[np.ndarray], output_video_path: str = None)
| 600 | |
| 601 | |
| 602 | def export_to_video(video_frames: List[np.ndarray], output_video_path: str = None) -> str: |
| 603 | if is_opencv_available(): |
| 604 | import cv2 |
| 605 | else: |
| 606 | raise ImportError(BACKENDS_MAPPING["opencv"][1].format("export_to_video")) |
| 607 | if output_video_path is None: |
| 608 | output_video_path = tempfile.NamedTemporaryFile(suffix=".mp4").name |
| 609 | |
| 610 | fourcc = cv2.VideoWriter_fourcc(*"mp4v") |
| 611 | h, w, c = video_frames[0].shape |
| 612 | video_writer = cv2.VideoWriter(output_video_path, fourcc, fps=8, frameSize=(w, h)) |
| 613 | for i in range(len(video_frames)): |
| 614 | img = cv2.cvtColor(video_frames[i], cv2.COLOR_RGB2BGR) |
| 615 | video_writer.write(img) |
| 616 | return output_video_path |
| 617 | |
| 618 | |
| 619 | def load_hf_numpy(path) -> np.ndarray: |
nothing calls this directly
no test coverage detected