MCPcopy Create free account
hub / github.com/dcharatan/flowmap / video_to_frames

Function video_to_frames

flowmap/subsample.py:70–80  ·  view source on GitHub ↗

Convert a full video to frames using ffmpeg.

(
    in_path: Path,
    out_path: Path,
    limit_num_seconds: float | None,
)

Source from the content-addressed store, hash-verified

68
69
70def video_to_frames(
71 in_path: Path,
72 out_path: Path,
73 limit_num_seconds: float | None,
74) -> None:
75 """Convert a full video to frames using ffmpeg."""
76 out_path.mkdir(exist_ok=True, parents=True)
77 limit = None if limit_num_seconds is None else f"-t {limit_num_seconds}"
78 command = f"ffmpeg -i {in_path} {limit} {out_path}/frame_%06d.png"
79 if subprocess.run(command.split(" ")).returncode != 0:
80 raise ValueError("ffmpeg conversion failed")
81
82
83def resize_to_resolution(

Callers 1

subsampleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected