Convert a folder of images to a video. Args: input_folder (str): input image folder output_path (str): output video file path remove_raw_file (bool, optional): whether remove raw images. Defaults to False. img_format (str, optional): format to name th
(input_folder: str,
output_path: str,
remove_raw_file: bool = False,
img_format: str = '%06d.png',
fps: Union[int, float] = 30,
resolution: Optional[Union[Tuple[int, int],
Tuple[float, float]]] = None,
start: int = 0,
end: Optional[int] = None,
disable_log: bool = False)
| 668 | |
| 669 | |
| 670 | def images_to_video(input_folder: str, |
| 671 | output_path: str, |
| 672 | remove_raw_file: bool = False, |
| 673 | img_format: str = '%06d.png', |
| 674 | fps: Union[int, float] = 30, |
| 675 | resolution: Optional[Union[Tuple[int, int], |
| 676 | Tuple[float, float]]] = None, |
| 677 | start: int = 0, |
| 678 | end: Optional[int] = None, |
| 679 | disable_log: bool = False) -> None: |
| 680 | """Convert a folder of images to a video. |
| 681 | |
| 682 | Args: |
| 683 | input_folder (str): input image folder |
| 684 | output_path (str): output video file path |
| 685 | remove_raw_file (bool, optional): whether remove raw images. |
| 686 | Defaults to False. |
| 687 | img_format (str, optional): format to name the images]. |
| 688 | Defaults to '%06d.png'. |
| 689 | fps (Union[int, float], optional): output video fps. Defaults to 30. |
| 690 | resolution (Optional[Union[Tuple[int, int], Tuple[float, float]]], |
| 691 | optional): (height, width) of output. |
| 692 | defaults to None. |
| 693 | start (int, optional): start frame index. Inclusive. |
| 694 | If < 0, will be converted to frame_index range in [0, frame_num]. |
| 695 | Defaults to 0. |
| 696 | end (int, optional): end frame index. Exclusive. |
| 697 | Could be positive int or negative int or None. |
| 698 | If None, all frames from start till the last frame are included. |
| 699 | Defaults to None. |
| 700 | disable_log (bool, optional): whether close the ffmepg command info. |
| 701 | Defaults to False. |
| 702 | Raises: |
| 703 | FileNotFoundError: check the input path. |
| 704 | FileNotFoundError: check the output path. |
| 705 | |
| 706 | Returns: |
| 707 | None |
| 708 | """ |
| 709 | check_input_path( |
| 710 | input_folder, |
| 711 | allowed_suffix=[], |
| 712 | tag='input image folder', |
| 713 | path_type='dir') |
| 714 | prepare_output_path( |
| 715 | output_path, |
| 716 | allowed_suffix=['.mp4'], |
| 717 | tag='output video', |
| 718 | path_type='file', |
| 719 | overwrite=True) |
| 720 | input_folderinfo = Path(input_folder) |
| 721 | num_frames = len(os.listdir(input_folder)) |
| 722 | start = (min(start, num_frames - 1) + num_frames) % num_frames |
| 723 | end = (min(end, num_frames - 1) + |
| 724 | num_frames) % num_frames if end is not None else num_frames |
| 725 | temp_input_folder = None |
| 726 | if img_format is None: |
| 727 | temp_input_folder = os.path.join(input_folderinfo.parent, |
no test coverage detected