MCPcopy Index your code
hub / github.com/huggingface/diffusers / export_to_video

Function export_to_video

tests/testing_utils.py:1048–1062  ·  view source on GitHub ↗
(video_frames: list[np.ndarray], output_video_path: str = None)

Source from the content-addressed store, hash-verified

1046
1047
1048def 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
1065def load_hf_numpy(path) -> np.ndarray:

Callers 5

save_model_cardFunction · 0.90
log_validationFunction · 0.90
save_model_cardFunction · 0.90
log_validationFunction · 0.90

Calls 1

is_opencv_availableFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…