(video_frames: list[np.ndarray], output_video_path: str = None)
| 847 | |
| 848 | |
| 849 | def export_to_video(video_frames: list[np.ndarray], output_video_path: str = None) -> str: |
| 850 | if is_opencv_available(): |
| 851 | import cv2 |
| 852 | else: |
| 853 | raise ImportError(BACKENDS_MAPPING["opencv"][1].format("export_to_video")) |
| 854 | if output_video_path is None: |
| 855 | output_video_path = tempfile.NamedTemporaryFile(suffix=".mp4").name |
| 856 | |
| 857 | fourcc = cv2.VideoWriter_fourcc(*"mp4v") |
| 858 | h, w, c = video_frames[0].shape |
| 859 | video_writer = cv2.VideoWriter(output_video_path, fourcc, fps=8, frameSize=(w, h)) |
| 860 | for i in range(len(video_frames)): |
| 861 | img = cv2.cvtColor(video_frames[i], cv2.COLOR_RGB2BGR) |
| 862 | video_writer.write(img) |
| 863 | return output_video_path |
| 864 | |
| 865 | |
| 866 | def load_hf_numpy(path) -> np.ndarray: |
nothing calls this directly
no test coverage detected
searching dependent graphs…