nicetoolbox.utils.video.split_into_frames¶
- nicetoolbox.utils.video.split_into_frames(video_file: str, output_base: str, start_frame: int | None = None, number_of_frames: int | None = None, skip_frames: int | None = None, keep_indices: bool = True) tuple[source]¶
Split a video into individual frames.
- Parameters:
video_file (str) – Path to the input video file.
output_base (str) – Base directory where the frames will be saved.
start_frame (int, optional) – The starting frame index. Defaults to None.
number_of_frames (int, optional) – The number of frames to extract. Defaults to None.
skip_frames (int, optional) – The number of frames to skip between each extracted frame. Defaults to None.
keep_indices (bool, optional) – Whether to keep the original frame indices or convert them to sequential numbers. Defaults to True.
- Returns:
- A tuple containing two lists - the list of
extracted frame filenames and the list of corresponding frame indices.
- Return type:
Tuple[List[str], List[int]]
- Raises:
AssertionError – If splitting the video into frames fails.
Note
- This function uses ffmpeg to split the video into frames. Make sure ffmpeg
is installed and accessible in the system’s PATH.
Warning
- The skip_frames option is not properly working yet. Its output is not fully
understood yet.