Title: Need advice connecting n8n Cloud + Leonardo API + Windows FFmpeg for unattended video production

Title: Need advice connecting n8n Cloud + Leonardo API + Windows FFmpeg for unattended video production

Hello n8n Community,

I’m building an automated YouTube video production workflow using n8n Cloud, Google Drive, Leonardo AI, Python, and FFmpeg on Windows.

What is already working:

  • Google Drive job JSON generation and readback

  • Windows Python + FFmpeg rendering a real 1920×1080, 30fps MP4

  • A render_done JSON receipt containing job ID, SHA256, and technical QA results

  • n8n detecting a real rendering receipt and automatically creating an ACK

  • No paid API calls during the verification

What is not yet fully verified:

  1. The latest ACK test used an existing real rendering receipt, replayed as a new event. It did not trigger a fresh render.

  2. We still need to verify the entire unattended chain for a brand-new job.

  3. Leonardo character-reference image generation needs a controlled one-image test before batch production.

Our questions:

  1. What is the most reliable n8n Cloud pattern to handle Google Drive job and receipt files without frequent polling?

  2. How should we implement idempotency so replayed receipts never create duplicate jobs, ACKs, or paid API calls?

  3. How should n8n verify a real renderer output rather than trusting only JSON metadata such as VERIFIED_CANDIDATE?

  4. How should we safely connect Leonardo’s image generation API with character references, asynchronous job completion, and an approval gate?

  5. Can we preserve our existing Windows FFmpeg runner while preparing to migrate rendering to a cloud service later?

Constraints:

  • Reuse existing workflows and working components

  • No unnecessary new workflows

  • No repeated paid image generation

  • No automatic YouTube publishing

  • Keep n8n Cloud executions and API costs low

  • Preserve all previously approved assets

We would appreciate practical recommendations or examples that fit this existing architecture.

Thank you very much for your help!

You’ve already established a solid foundation. I’d focus on making the existing pipeline event-driven, idempotent, and independently verifiable before increasing production volume.

A few practical recommendations:

1. Reduce polling and unnecessary executions
If your Google Drive setup supports reliable change notifications, use them to trigger the existing workflow. Otherwise, use a modest scheduled check with a persisted cursor or file version tracking. Treat notifications as signals to inspect the file, not as proof that a job is ready.

2. Make idempotency persistent
Assign every job a stable job_id and maintain explicit states such as pending, rendering, completed, and acknowledged. Enforce uniqueness in persistent storage for job IDs and receipt IDs. A replayed receipt should return the existing result rather than create another render, ACK, or paid API request.

3. Verify the actual rendered artifact
Don’t trust VERIFIED_CANDIDATE or a JSON receipt alone. Have the Windows runner independently check that the expected MP4 exists, has a non-zero size, matches the job ID, and passes FFprobe checks for resolution, frame rate, duration, and streams. Calculate the SHA-256 from the finished file and compare it with the receipt. For stronger verification, have the orchestrator independently retrieve or inspect the artifact where practical.

4. Handle Leonardo asynchronously
Start with one controlled image-generation request. Persist the provider’s request ID, poll only while the job is pending using bounded delays, and reuse the stored result on retries. Keep character-reference inputs and generated asset IDs linked to the job. Put an explicit human approval gate before batch generation or any further paid calls.

5. Keep the Windows renderer and make migration easier
Keep FFmpeg behind a small, stable rendering interface. Let n8n submit a job and receive a structured completion receipt regardless of whether the renderer runs on Windows today or a cloud worker later. That way, migration won’t require redesigning the orchestration logic.

I’d also test the complete chain with one brand-new job ID, from job creation through a fresh render, artifact verification, receipt processing, and ACK creation. Then replay the same receipt and confirm that no additional render or paid API call occurs.

I’ve been working on similar reliability patterns in an n8n + FastAPI + PostgreSQL demo, including idempotency, duplicate detection, conflict handling, failure recovery, and operational metrics. The key lesson is to make retries safe and verify side effects independently.

Portfolio: GitHub - katreshital11-commits/ai-n8n-automation: "Production-ready and test-proven n8n AI workflows, automated CRM pipelines, and custom AI Agent architectures." · GitHub

Here are a few ways to make that concrete in n8n Cloud:

  • Skip Drive polling for receipts. Have the Windows runner POST the receipt to a Webhook node (header auth) when the render finishes, and still write the file to Drive as the archive. Google Drive Trigger polls anyway, so this is the cheapest way to cut executions, and it works unchanged if the renderer moves to a cloud worker later.
  • Idempotency: make the first step a lookup in a Data Table (or Remove Duplicates set to compare against previous executions) keyed on job_id and receipt SHA256. If the key exists, exit; otherwise insert it. Put every paid call and ACK after that step.
  • Verify the MP4 without downloading it: include the file size and MD5 in the receipt and then compare against the file’s metadata from Drive (the API exposes size and md5Checksum, via the Drive node’s fields option or an HTTP Request).
  • Leonardo: start the generation with an HTTP Request, then a Wait node to resume on a callback (or a bounded wait loop), and use Send and Wait for Response as the approval gate before any batch.

@skqnwk886 I’d keep your existing setup and focus on making the complete workflow reliable before adding anything new.

Use Google Drive triggers where possible, and implement job-ID-based idempotency to prevent duplicate renders, ACKs, and paid API calls. Verify the actual MP4 using FFprobe for duration, resolution, frame rate, and file integrity rather than trusting the receipt JSON alone.

For Leonardo, test one character-reference image first, handle asynchronous generation, and add a manual approval step before batch generation.

The next priority is to test one completely new job from Google Drive through Windows rendering, QA verification, and ACK creation, then replay the same event to confirm no duplicates occur. This will validate your existing architecture while keeping costs low and leaving room for future cloud rendering.

Hello @skqnwk886 ,a few practical answers to your list:

  • Polling: instead of Drive polling, have the Windows runner call an n8n webhook when a job or receipt is done, so n8n only runs on real events.
  • Idempotency: key everything on job ID plus the receipt’s SHA256, store that key before any paid call, and skip when it already exists. A replayed receipt then does nothing.
  • Trusting the output: have the runner upload the MP4 and send a checksum Drive also reports (Drive reports MD5), then compare it to the uploaded file before the ACK counts.
  • Leonardo: send one image, then use a Wait node that resumes on a webhook, with an approval step before any batch. The runner can stay as it is, and a cloud renderer can later replace it behind the same webhook.

Pond AI could help build and run a pipeline like this. It’s an AI engineer on call that designs, builds and keeps custom agents and workflows running, and it sketches the architecture for free first, with a 7-day refund on custom builds.

When you move rendering to the cloud, which part worries you most, cost or reliability? If it sounds useful, I’d be glad to introduce you to the founder or the team.

Disclosure: I’m affiliated with Pond AI

polling generation webhooks rather than holding open http request nodes avoids gateway timeouts when rendering high resolution video segments.

for orchestrating multi scene video pipelines, queueing our script assets and image batches through blotato allows us to assemble stitched video clips automatically without maintaining dedicated local rendering workers.

are you stitching audio tracks during the ffmpeg step or generating subtitles inside the same command?

Hi @skqnwk886, three things for the unattended part that I haven’t seen covered:

  1. Write the receipt last. The runner should finish and upload the MP4 first, and only then write the render_done receipt, so n8n never reads a receipt that points to a half-uploaded file. Treat approved assets as write-once: new versions go in a new folder or filename, never over an approved file.
  2. A heartbeat from the Windows runner. The usual failure on an unattended Windows machine is a reboot, a sleep or an update, and nothing fails visibly. Have the runner ping an n8n webhook every few minutes, and have a scheduled check alert you when the ping is silent or when a job has been “rendering” longer than a normal render takes.
  3. Unknown outcomes on paid calls. If a Leonardo request times out after you’ve sent it, you may already have been charged. Save the generation ID as soon as you get it and check status by ID instead of resubmitting. Add a daily cap on paid calls in a small counter, so a bug can’t loop into a large bill.

Full disclosure: I’m affiliated with Pond AI, where we build custom AI agents and workflows. Pond AI offers a free architecture plan you can keep even if you build it yourself or hire someone else, plus a 7-day refund if you work with us.

Does the Windows machine run 24/7 for this, or only when you start a batch?

One additional reliability point: I’d keep the job state separate from the rendering receipt. A receipt should be accepted only when its job ID matches an existing job and the actual MP4 passes independent validation.

For duplicate protection, a PostgreSQL record with a unique job/operation key can prevent concurrent executions from claiming the same render or paid API step. I’d also make the completion webhook safe to replay, so a repeated receipt cannot trigger another paid generation or create another ACK.

The key test would be a fresh job end to end, followed by replaying its receipt and checking that no additional render or paid API call occurs.

Hi @skqnwk886, “unattended” is the hard part, so the two weak points are the render step and the machine itself.

FFmpeg: a crashed or killed process leaves a zero-byte or truncated MP4 that still “exists,” so the flow thinks it succeeded. Check the FFmpeg exit code, then ffprobe the output for a valid duration/stream before you upload or write the done receipt. Anything that fails goes to a retry queue, not to the client.

Leonardo: a generation can return failed or content-blocked, which isn’t an HTTP error, so handle that status separately from timeouts, and catch 402 when credits run out, since that one fails quietly at scale. Store the generation ID before you poll so a restart resumes instead of re-paying.

The runner: unattended means it survives a reboot. Run it as a Windows service or a Task Scheduler job with restart-on-failure, not a logged-in session, and have it send a heartbeat so you learn it died rather than finding out from empty output.

Disclosure: I’m affiliated with Pond AI. Pond AI builds, runs and maintains custom AI agents, so pipelines like this keep working past demo day. Happy to map the full architecture for you for free to keep either way, and anything we build is covered by a 7-day refund.

What’s your volume, a few renders a day or closer to continuous?

Hi, you’ve already gotten solid advice on webhooks, ffprobe and idempotency, so I’ll point only at the places those exact patterns quietly fail on n8n Cloud at real volume, which is where “unattended” actually bites.

The idempotency check most people here described has a race in it. “Look up the key, if it’s missing insert it and render” lets two near-simultaneous events, say a replayed receipt arriving while the original is still in flight, both pass the lookup before either writes, so both render or both pay Leonardo. Flip it: make the first write an atomic claim. Insert the job/receipt key against a unique constraint and continue only if you won the insert; if the insert conflicts, you are the duplicate, exit. “Insert first, act second” is race-safe. “Check first, act second” is not.

Your receipt webhook will also be hit more than once even with zero replay. A runner that retries a failed POST, which it should, means n8n gets at-least-once delivery, so you need to dedupe on an idempotency key the runner stamps in the header, separate from the Drive-file replay case. Two different sources of duplicates, one dedupe store.

For the Drive side without polling, don’t cursor on modifiedTime. Client clock skew and same-second writes make it miss files or read them twice. Use Drive’s changes API with a persisted startPageToken, and advance the token only after you’ve durably recorded what you processed. That’s the real “no frequent polling” answer, and it survives a restart instead of losing its place.

Watch the approval gate on n8n Cloud in particular. A Wait or Send-and-Wait that pauses for a human for hours is a single long-lived paused execution, and that’s a fragile thing to hang an approved-asset pipeline on across instance restarts or retention windows. Safer: persist an “awaiting approval” state in your store, and have the approval click POST to a small lookup webhook that re-enters the flow by job ID. The decision lives in your data, not in a paused execution.

On the character references themselves, which I haven’t seen actually answered: consistency comes from pinning the seed and reusing the same uploaded reference-image ID across the batch, not from re-describing the character on each call. Upload the reference once, store its ID alongside the job, and reuse it. Also handle that reference IDs can expire, so refresh and re-store the ID rather than letting a batch fail halfway through.

The diagram walks the whole race-safe chain: Drive changes-token ingest into the receipt webhook, the atomic claim with its conflict-exit branch, independent verification, Leonardo with reference-ID and pinned seed, and the durable approval gate, with the four guardrails that keep it alive unattended along the bottom.

Full disclosure, I’m affiliated with Pond AI. The gap this whole thread is circling is exactly why we exist: builds that pass a demo but quietly die unattended at 2am. We build, run and maintain custom AI agents so they keep working past that point. The architecture plan is yours to keep for free whether you build it in-house or hand it to any dev you like, no strings; the 7-day refund only applies if you build it with us.

Where does your job state actually live right now, and can that thing enforce a real uniqueness constraint? That single choice is the hinge for whether the atomic-claim fix is one node or needs a proper datastore underneath it.

You have already got the hard piece working. The gap here is making the unattended part safe so a replayed receipt can burn money

The order I would do:

  • Trigger on event not drive polling. Have the window runner post the receipt to an n8n webhook when the render is actually done and keep drive as the archive. That cuts cloud execution and still works later if you swap the runner for a cloud worker.

  • receipt last. Upload the mp4 first ffprobe it , then write render_done. Never ACK on JSON alone, compare drive file size to the receipt before ACK

  • idempotency before any paid steps. Key on job_id + receipt hash. If the key already exits , exit. Put Leonardo and ACK after that gate so a replay does nothing

  • Leonardo: one image then stop. Store the generation id as soon as you get it, wait or resume on status, needs human approval before any batch. Don’t resubmit on timeout, check by id

  • keep your windows ffmperg rubber as is behind the same web hook contract so a future cloud render is a drop in swap not a rebuild

Next test; one brand new job, end-end, then replay the same receipt and confirm zero extra render/leornado calls/ACKs

Full disclosure; I’m affiliated with pond ai. Pond ai builds, runs and maintain custom ai agent. Happy to map this architecture for free first.(you keep it even if you hire someone else) and there’s a 7 days refund if you build with them

Quick one, does the window box stay 24/7 or only when you kick a batch

@skqnwk886 , since the idempotency and verification angles are well covered, here are the ones that bite specifically because this is video on n8n Cloud, which I haven’t seen mentioned.

Don’t move the media bytes through n8n. A 1080p MP4, and even a batch of Leonardo stills, passed from node to node bloats execution data and runs into n8n Cloud’s payload and memory limits. Keep the workflow passing references only, Drive file IDs or URLs, and let the Windows runner and Drive handle the actual bytes. n8n should orchestrate, not carry the file.

Render in scene segments, not one long pass, and cache each segment by a hash of its inputs (script line, image IDs, encoder settings). Then a one-line script fix re-renders only that scene and re-stitches, instead of burning a full render and the time again. It also makes the chain resumable, a crash at scene 7 of 10 picks up at 7, and it’s the cheapest insurance you have on long videos.

Checkpoint idempotency per step, not just per job. Image generation and rendering are separate expensive stages, so record completion of each with its own key. A mid-pipeline restart then resumes from the last finished step rather than re-running image-gen you already paid for. Job-level dedupe stops a duplicate job; step-level checkpoints stop you re-paying inside one.

Put an overlap lock on the schedule. The classic unattended failure is a nightly run that takes longer than expected while the next trigger fires on top of it, and now two runs fight over the same files. Before a scheduled run starts, check for and claim a lock; if one is held, skip or queue, don’t stack.

One thing from earlier in the thread that went unanswered: audio and subtitles. Do the audio mux and any subtitle burn-in as the final deterministic ffmpeg step on the already-approved visuals, kept entirely out of the paid image-gen path, so a subtitle tweak never risks a re-generation.

Full disclosure, I’m affiliated with Pond AI. We build, run and maintain custom AI agents, and scaling a multi-scene pipeline past a demo, segment caching, resumable state, keeping n8n as an orchestrator rather than a file mover, is exactly the kind of thing we set up so it stays standing. The architecture plan is yours to keep for free, build it in-house or hand it to any developer you like, no strings; the 7-day refund only applies if you build it with us.

How long are the finished videos, and are you rendering them as one pass or already cut into scenes? That’s the fork for whether segment caching earns its keep here.

Your ACK test passing on a replayed receipt is the useful clue here: the workflow is currently keyed on the *event*, not on the *job*. Three fixes, roughly in order of how much money they save you.

**1. Key on job_id, not on the receipt.**

Keep every job in one persistent table (n8n Data Table, Postgres, Supabase — anything that survives the execution). Columns: job_id (unique), attempt, state (pending/rendering/rendered/acked), receipt_sha256, artifact_sha256, provider_generation_id, updated_at. Before doing anything, claim the job with INSERT … ON CONFLICT (job_id, attempt) DO NOTHING, and continue only if a row came back. A replayed receipt then hits the conflict and returns the stored state instead of starting a second render or a second paid Leonardo call. Execution history is not a lock — two executions can be in flight at once.

**2. Hash the receipt body, not just its name.**

job_id + sha256(receipt JSON) is what separates a replay from a genuine retry of the same job after a failure. Same hash = duplicate, drop it silently. Different hash = new attempt, allowed.

**3. Verify the artifact, not the metadata.**

Have the Windows runner compute the hash of the finished MP4 *after* ffmpeg exits 0 (not of the file it meant to write), and put size + sha256 + ffprobe duration/resolution into the receipt. In n8n then: Drive download the file, Crypto node (SHA256 on the binary), compare. Mismatch = job not done, whatever VERIFIED_CANDIDATE claims. That is the only check that survives a truncated file or an encoder that exited early.

Same keying for Leonardo: persist provider_generation_id against job_id *before* you start polling, and reuse it on retry — otherwise every retry buys another image.

On Drive: use changes.getStartPageToken + changes.list with the token persisted; treat a change as “go look”, then list files created after your cursor. A scheduled 5-minute pass is a fine fallback. Polling by listing the folder and diffing names is where duplicate events come from.

One extra that pays for itself: have the runner write a heartbeat file every 60s. Then “runner dead” and “runner idle” are distinguishable, and you stop re-queueing jobs that are actually rendering.

I do this kind of work — wiring a state machine and a verification layer around a renderer that already works. If it’s useful I can post the idempotency + verification part as a workflow JSON here (it’s a pattern, no charge). If you want the whole unattended chain built and tested end to end against your existing Python/FFmpeg runner, say so and we can scope it.

Hi @skqnwk886, a lot of good ground is already covered here, so I’ll stick to the parts that decide whether this runs unattended without a surprise bill, which I haven’t seen raised yet.

Give yourself a dry-run mode. You said no paid calls during verification, so bake that in as a flag rather than a discipline: a MOCK switch that short-circuits the Leonardo node with a canned response and a sample asset, so you can run the entire chain, job creation through render, verify, ACK and approval, as many times as you like for free. Real credits only burn when the flag is off. That turns “we still need to verify the whole chain” from a risky live test into something you repeat daily.

Split your errors into retryable and terminal, and treat them differently. A timeout or a 429 is worth retrying with exponential backoff plus jitter and a hard attempt cap. A 402 (out of credits), a content-blocked result or a 400 is terminal, and retrying those just wastes calls and can re-charge you. Anything that exhausts its retries goes to a dead-letter store you can inspect, not back onto the queue. A “retry queue” without that split quietly becomes an infinite loop or a silent bill.

Mind Leonardo’s rate and concurrency limits once you go to batch. A loop that fires generations as fast as n8n can will hit 429s; respect the Retry-After header and cap how many generations are in flight at once. One throttled request shouldn’t stall the whole night.

Keep a tiny per-job ledger: job_id, generation_id, credits spent, render seconds, outcome. Unattended means you won’t be watching, so this is how you answer “what did last night cost and what failed” in one glance instead of scrolling executions.

Two quieter traps. Keep API keys out of the job JSON on Drive. That file gets read, copied and archived, so any key sitting in it leaks; put keys in n8n credentials and give the webhook a shared secret you can rotate. And if you ever re-render a job, non-deterministic ffmpeg encoding changes the output bytes, so a fresh SHA256 won’t match the old receipt. Pin your encoder settings, and ideally the ffmpeg version, if you’re leaning on that hash as a verification or dedupe signal.

Full disclosure, I’m affiliated with Pond AI. We build, run and maintain custom AI agents, and the unglamorous parts above, the retry taxonomy, the rate-limit handling, the credit ledger, are exactly what we wire in so a pipeline doesn’t surprise you with a bill or a silent stall. The architecture map is yours to keep for free, build it yourself or hand it to any dev you trust, no strings; the 7-day refund only applies if you build it with us, so trying us is our risk, not yours.

Out of cumriosity, how are you exercising the chain today without spending credits, mocking Leonardo’s response, or running one small real generation each pass?