in augly/video/augmenters/ffmpeg/concat.py [0:0]
def get_command(self, video_path: str, output_path: str) -> List[str]:
"""
Concatenates multiple videos together
@param video_path: the path to the video to be augmented
@param output_path: the path in which the resulting video will be stored.
@returns: a list of strings containing the CLI FFMPEG command for
the augmentation
"""
inputs = [["-i", video] for video in self.video_paths]
flat_inputs = [element for sublist in inputs for element in sublist]
scale_and_sar, maps = "", ""
for i in range(len(self.video_paths)):
scale_and_sar += (
f"[{i}:v]scale={self.width}:{self.height}[{i}v],[{i}v]setsar=ratio="
f"{self.sample_aspect_ratio}[{i}vf];"
)
for i in range(len(self.video_paths)):
maps += f"[{i}vf][{i}:a]"
rest_command = f"concat=n={len(self.video_paths)}:v=1:a=1[v][a]"
return [
"-y",
*flat_inputs,
"-filter_complex",
scale_and_sar + maps + rest_command,
"-map",
"[v]",
"-map",
"[a]",
"-vsync",
"2",
*self.output_fmt(output_path),
]