$AI Income Hub
HomeAI VideoAutomated Product Comparison Video Generation Pipeline
AI Video

Automated Product Comparison Video Pipeline

A technical guide to building an audio-driven video automation system that prevents desync by calculating TTS duration before rendering visuals.
Automated Product Comparison Video Generation Pipeline

Stop building video-first timelines

The most common failure in automation is recording a fixed-length video clip and trying to fit speech into it. This leads to audio cutting off or awkward gaps. To fix this, you must treat audio duration as the primary driver. Synthesize your audio first, measure the exact millisecond length using ffprobe, and then tell your headless browser to record for that specific duration. If you don't do this, your videos will feel amateur and disjointed.

Technical stack and real-world costs

I have found that running this on a local M-series Mac or a Linux VPS with at least 4 vCPUs is necessary to avoid Chromium crashing during render. You will need Python 3.10+, ffmpeg (version 5.0 or higher), and Playwright for browser control. Regarding costs, if you use local engines like VOICEVOX or the free edge-tts library, your software cost is $0. If you scale to a paid API like ElevenLabs, expect to spend $40 to $100 per month for a volume of roughly 50 high-quality videos. Be warned: engineering this takes about 20 to 30 hours of actual coding before the pipeline is stable enough to run without manual intervention.

How to prevent audio desync

To avoid the "choppy" feel of automated videos, implement a bottom-up duration logic. Do not process scenes sequentially; use Python's concurrent.futures to trigger multiple TTS requests in parallel to reduce total render time. The logic flow must be: parse JSON data, generate .wav files, extract duration via ffprobe, and then pass that total time (including a 0.25s buffer gap) to the Chromium recorder. This ensures the visual stage stays active exactly as long as the voiceover is speaking.

When to avoid this method

Do not use this pipeline if your content requires high-precision timing with music beats or complex 3D animations. This system is designed for structured data—like product spec comparisons—where a static HTML page with CSS animations is sufficient. If you need cinematic transitions, this headless browser approach will be too rigid and will break your creative flow.

Handling variable clip lengths during joining

Even with audio-first logic, slight drifts occur when stitching multiple .mp4 segments. A simple concatenation often results in audible pops or visual jumps. To solve this, use an ffmpeg filtergraph. Instead of joining raw clips, concatenate the audio files first and use the apad filter to stretch the audio to the calculated duration. This removes the "stutter" effect and allows for professional-grade cross-fades between product comparisons.

Managing the risk of failure

The biggest risk is the "headless hang," where Chromium fails to capture a frame or the TTS API timeouts. If your script doesn't include a retry loop with a timeout, one failed API call will crash a batch of 100 videos. Always implement a checksum to verify that the generated .mp4 file size is greater than 0 bytes before moving to the next scene, or you will end up with a final video full of black screens.

#content creation#video automation#ffmpeg#python workflow