I have a Python script that automates trimming a large video (2 hours) into smaller segments and then concatenating them without re-encoding, to keep the process fast. The script runs these ffmpeg commands:
import subprocess
# Extract chunks
segments = [(0, 300), (300, 600), (600, 900)] # example segments in seconds
for i, (start, length) in enumerate(segments):
subprocess.run([
"ffmpeg", "-i", "input.mp4", "-ss", str(start), "-t", str(length),
"-c", "copy", "-reset_timestamps", "1", "-y", f"chunk_i.mp4"
], check=True)
# Create concat (...)