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

Function spatial_concat_video

detrsmpl/utils/ffmpeg_utils.py:1101–1192  ·  view source on GitHub ↗

Spatially concat some videos as an array video. Args: input_path_list (list): input video or gif file list. output_path (str): output video or gif file path. array (List[int], optional): line number and column number of the video array]. Defaults to [1, 1].

(input_path_list: List[str],
                         output_path: str,
                         array: List[int] = [1, 1],
                         direction: Literal['h', 'w'] = 'h',
                         resolution: Union[Tuple[int,
                                                 int], List[int], List[float],
                                           Tuple[float, float]] = (512, 512),
                         remove_raw_files: bool = False,
                         padding: int = 0,
                         disable_log: bool = False)

Source from the content-addressed store, hash-verified

1099
1100
1101def spatial_concat_video(input_path_list: List[str],
1102 output_path: str,
1103 array: List[int] = [1, 1],
1104 direction: Literal['h', 'w'] = 'h',
1105 resolution: Union[Tuple[int,
1106 int], List[int], List[float],
1107 Tuple[float, float]] = (512, 512),
1108 remove_raw_files: bool = False,
1109 padding: int = 0,
1110 disable_log: bool = False) -> None:
1111 """Spatially concat some videos as an array video.
1112
1113 Args:
1114 input_path_list (list): input video or gif file list.
1115 output_path (str): output video or gif file path.
1116 array (List[int], optional): line number and column number of
1117 the video array]. Defaults to [1, 1].
1118 direction (str, optional): [choose in 'h' or 'v', represent
1119 horizontal and vertical separately].
1120 Defaults to 'h'.
1121 resolution (Optional[Union[Tuple[int, int], Tuple[float, float]]],
1122 optional): (height, width) of output.
1123 Defaults to (512, 512).
1124 remove_raw_files (bool, optional): whether remove raw images.
1125 Defaults to False.
1126 padding (int, optional): width of pixels between videos.
1127 Defaults to 0.
1128 disable_log (bool, optional): whether close the ffmepg command info.
1129 Defaults to False.
1130 Raises:
1131 FileNotFoundError: check the input path.
1132 FileNotFoundError: check the output path.
1133
1134 Returns:
1135 None
1136 """
1137 lowercase = string.ascii_lowercase
1138 assert len(array) == 2
1139 assert (array[0] * array[1]) >= len(input_path_list)
1140 for path in input_path_list:
1141 check_input_path(
1142 path,
1143 allowed_suffix=['.gif', '.mp4'],
1144 tag='input video',
1145 path_type='file')
1146 prepare_output_path(
1147 output_path,
1148 allowed_suffix=['.gif', '.mp4'],
1149 tag='output video',
1150 path_type='file',
1151 overwrite=True)
1152
1153 command = ['ffmpeg']
1154 height, width = resolution
1155 scale_command = []
1156 for index, vid_file in enumerate(input_path_list):
1157 command.append('-i')
1158 command.append(vid_file)

Callers

nothing calls this directly

Calls 3

check_input_pathFunction · 0.90
prepare_output_pathFunction · 0.90
printFunction · 0.50

Tested by

no test coverage detected