MCPcopy Create free account
hub / github.com/AlayaLab/Hive / export_to_video

Function export_to_video

models/flowsep/diffusers/utils/testing_utils.py:301–315  ·  view source on GitHub ↗
(video_frames: List[np.ndarray], output_video_path: str = None)

Source from the content-addressed store, hash-verified

299
300
301def export_to_video(video_frames: List[np.ndarray], output_video_path: str = None) -> str:
302 if is_opencv_available():
303 import cv2
304 else:
305 raise ImportError(BACKENDS_MAPPING["opencv"][1].format("export_to_video"))
306 if output_video_path is None:
307 output_video_path = tempfile.NamedTemporaryFile(suffix=".mp4").name
308
309 fourcc = cv2.VideoWriter_fourcc(*"mp4v")
310 h, w, c = video_frames[0].shape
311 video_writer = cv2.VideoWriter(output_video_path, fourcc, fps=8, frameSize=(w, h))
312 for i in range(len(video_frames)):
313 img = cv2.cvtColor(video_frames[i], cv2.COLOR_RGB2BGR)
314 video_writer.write(img)
315 return output_video_path
316
317
318def load_hf_numpy(path) -> np.ndarray:

Callers

nothing calls this directly

Calls 1

is_opencv_availableFunction · 0.85

Tested by

no test coverage detected