import subprocess from rich.console import Console from dubbing.steps.base import PipelineStep console = Console() class FinalizeStep(PipelineStep): name = "Finalize" def is_cached(self) -> bool: return self.paths.result_video.exists() def clean(self) -> None: if self.paths.result_video.exists(): self.paths.result_video.unlink() async def run(self) -> None: console.print("[cyan]Creating final video...[/]") subprocess.run( [ "ffmpeg", "-y", "-i", str(self.paths.source_video), "-i", str(self.paths.dubbed_audio), "-map", "0:v", "-map", "1:a", "-c:v", "copy", "-c:a", "copy", "-shortest", str(self.paths.result_video), ], capture_output=True, check=True, ) console.print(f"[green]✓ Created {self.paths.result_video}[/]")