One photo, one script: an image-to-video pipeline
How our Voxon AI Studio turns one photo and a script into a multi-minute talking video: Veo 3.1 clips each seeded from the same photo, bounded retries, and a lossless ffmpeg join.
In May 2026 we built Voxon AI Studio, a small tool with a simple promise. Upload one photo of a person and a script of up to 5,000 characters, and get back a video of that person speaking the script, a few minutes long.
The model we used, Google's Veo 3.1, generates video with native audio from an image and a prompt. But each generation is a clip of several seconds, not minutes. The work was everything around the model: cutting the script to fit, keeping the speaker looking like themselves, surviving rate limits and safety filters, and joining the pieces without losing quality.
The problem
- Clips are short. A clip covers roughly 6 to 8 seconds of speech. A two-minute script needs a dozen or more generations.
- Identity drifts. Every generation is a fresh sample. Ask for twenty clips and you risk twenty slightly different people.
- Generation fails in more than one way. Rate limits, transient errors that return no video, and content-safety filters that look alike in the response but need opposite handling.
- Each clip is slow and costs money. A job is minutes of wall-clock time, so it has to run in the background and report progress.
Architecture
It's deliberately small: one Node process running Express, serving a React 19 front end and three API endpoints for upload, generate and status.
photo + script -> /api/upload -> /api/generate-video (returns a task id)
-> split script into ~120-character chunks at sentence ends (max 20)
-> resize the photo once to a 1280x720 JPEG: the seed
-> for each chunk: Veo generateVideos(seed, chunk text)
poll every 10 s (give up at 600 s), download MP4
-> ffmpeg concat demuxer, -c copy -> <task>_final.mp4
-> temp files removed in finally
client polls /api/video-status/:id for progress Job state lives in an in-memory map keyed by task id, and files live on local disk. There's no database and no queue. That's the right size for a tool used by a few people, and its limits are written down: state is lost on restart, never evicted, and the process can't scale sideways.
The engineering
Cutting the script to the model
The chunker splits on sentence endings, then packs sentences into chunks of about 120 characters, which is roughly what Veo will speak in one clip. Unpunctuated text falls back to splitting at word boundaries. A script that produces no chunks or more than 20 is refused before any money is spent.
function chunkText(text: string, maxCharsPerChunk = 120): string[] {
let parts = text.match(/[^.!?]+[.!?]+/g);
// ...fallback: split at word boundaries...
for (const p of parts) {
const trimmed = p.trim();
if (!trimmed) continue;
const combined = current ? `${current} ${trimmed}` : trimmed;
if (combined.length > maxCharsPerChunk && current) {
chunks.push(current.trim());
current = trimmed;
} else {
current = combined;
}
} Breaking at sentence ends matters more than the exact length. A clip that ends mid-sentence sounds wrong, however clean the join.
Every clip from the same photo
One way to keep a long video continuous is to take the last frame of each clip and use it as the seed for the next. We don't do that. Every chunk is generated from the same seed photo, and the prompt is just the words to speak. The comment in the code gives the reasoning: every chunk re-seeds from the same image "to lock the narrator's identity — no chaining, no drift."
That's a real trade-off. Chaining gives smoother motion between clips, but each generation inherits the previous one's small errors, and over twenty clips a face can wander. Re-seeding from the original keeps the person recognisably the same in every clip, at the cost of a small reset in pose at each join. For a talking-head video, a consistent face matters more than continuous motion.
There's also no separate text-to-speech. Veo 3.1 generates the voice natively from the script text, spoken by the person in the photo. We probed a separate speech model in a one-off script and didn't need it.
Telling retryable failures from final ones
Veo reports filtered generations with a list of reasons, and the same field carries two very different things. Short category labels such as "Violence" or "Minor" mean the input itself was refused, and it will be refused again. Full sentences such as "processing issue" or "try again" mean a transient failure worth another attempt.
function isRetryableVeoReason(reasons: string[] | undefined): boolean {
if (!reasons || reasons.length === 0) return true; // empty = transient
const joined = reasons.join(" ").toLowerCase();
return joined.includes("audio for your prompt")
|| joined.includes("processing issue")
|| joined.includes("try again");
} So the retry policy has layers. Rate limits (429) get three attempts with a 15-second back-off when submitting and 10 seconds when polling. Transient generation failures get up to two attempts per chunk. Content-safety refusals fail fast with a clear message naming the chunk. Retrying those would only spend money to get the same answer.
A lossless join
Every clip comes from the same model with identical codec parameters, so the ffmpeg concat demuxer can join them with -c copy: no re-encode, no generation loss and almost no time. The temporary clips and the concat list are deleted in a finally block, so only the final MP4 survives, whether the job succeeds or fails.
This is the same trade we made in our 2015 video render service, which worked in uncompressed audio until the last step so nothing was compressed twice. Decide where quality is lost, and make it happen once.
Where AI fits
Here the AI is generative video, and it's a cloud model: Veo runs on Google's platform, called through the Gemini API. That's a deliberate choice for a creative tool where the input is a photo and a script someone chose to share. It isn't the choice we'd make for work data, where we run models ourselves, as in our generative AI and agents work.
The engineering is in how the model is used: the script text is the prompt, the photo anchors identity, chunk size matches clip length, and the 5,000-character and 20-chunk limits cap the cost of any single job. The full-quality model is the default, and a faster variant can be switched in by configuration for cheap iteration.
The tool was also built with AI. It was scaffolded in Google AI Studio and then developed with Claude Code, with a guide file in the repository telling future agents the commands, the architecture and the known limits.
What it taught us
That guide file taught us something too. It describes a last-frame chaining step that the code doesn't do; the shipped code re-seeds every clip from the original photo. Somewhere between design and delivery the approach changed and the notes didn't. When agents and people both read a project's notes as truth, the notes need the same review as the code. The fix is a habit: check what the docs say against what the code does before calling a piece of work finished.
The other lessons are familiar ones:
- Classify failures before retrying them. "Try again" and "never" can arrive in the same field.
- Put limits on cost up front. Refuse a job that's too big before the first paid call.
- Keep the tool the size of the job. An in-memory map was enough, and its limits were written down.
Why it still matters
Generative models are now good enough that the hard part of a product is rarely the model call. It's the pipeline around it: fitting the input to the model, handling its failure modes honestly, controlling cost and putting the pieces together without loss. Our AI work shows more of what we've built this way.