MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / images_to_video

Function images_to_video

detrsmpl/utils/ffmpeg_utils.py:670–776  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

668
669
670def 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,

Callers 4

inferenceFunction · 0.90
visualize_kp2dFunction · 0.90
render_kp3d_to_videoMethod · 0.90
exportMethod · 0.90

Calls 4

check_input_pathFunction · 0.90
prepare_output_pathFunction · 0.90
images_to_sorted_imagesFunction · 0.85
printFunction · 0.50

Tested by

no test coverage detected