惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
爱范儿
爱范儿
罗磊的独立博客
V
V2EX
量子位
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
Jina AI
Jina AI
博客园 - 叶小钗
小众软件
小众软件
博客园 - 【当耐特】
Y
Y Combinator Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
博客园 - 聂微东
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Generate 1,000+ personalized videos with a REST API (Node...
Renderly.Video · 2026-06-18 · via DEV Community

Your platform has 5,000 products and someone wants a personalized demo video for each one. By tomorrow.

You're not booking a studio. You're writing a loop. This post is that loop: a batch pipeline that queues thousands of template-based renders, verifies webhook callbacks, retries the flaky ones, and doesn't fall over at scale. Node.js throughout, with Python equivalents noted inline.

I'll skip the marketing case. Template rendering runs about $0.10 to $0.50 per video at volume against $1,000 to $7,000 a minute for agency footage, so the ROI was never the blocker. Production capacity was. Let's build.

What you're building

  • Template-driven generation with a JSON replacements payload
  • Bulk processing for 1,000+ videos with batching and rate limits
  • Webhook callbacks with HMAC signature verification
  • Exponential-backoff retries and explicit error-code handling

Stack: Renderly (video API), Node.js, Promise.allSettled for concurrency, webhooks for completion. A queue like BullMQ on Redis helps once you're past ~10k, but you don't need it to start.

The API foundation

One endpoint, Bearer auth, JSON bodies. Base URL renderly.video/api/v1.

const RENDERLY_API_KEY = process.env.RENDERLY_API_KEY;
const API_BASE_URL = 'https://renderly.video/api/v1';

async function createRender(templateId, replacements) {
  const res = await fetch(`${API_BASE_URL}/renders`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${RENDERLY_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ templateId, replacements }),
  });
  if (!res.ok) {
    const err = await res.json();
    throw new Error(`API ${res.status}: ${err.message}`);
  }
  return res.json(); // { id, status: 'pending', ... }
}

The template system: isDynamic, not {{ mustache }}

Most video API tutorials show {{ variable }} placeholders. Renderly is overlay-based instead, and this is the thing that trips people up on their first try.

Each overlay element carries an isDynamic flag. When it's true, that overlay's content becomes a named variable. Your request sends a replacements object keyed by overlay name, and the renderer matches by name to swap the value in. It replaces content for text and shape overlays, and src for image, video, and audio.

{
  "overlays": [
    { "type": "text",  "name": "product_name",  "content": "Default", "isDynamic": true },
    { "type": "image", "name": "product_image", "src": "https://cdn.example.com/default.jpg", "isDynamic": true },
    { "type": "text",  "name": "price", "content": "$0.00", "isDynamic": true },
    { "type": "text",  "content": "Powered by Acme Co.", "isDynamic": false }
  ]
}

That last overlay (isDynamic: false) is the brand watermark. It stays identical across all 1,000 videos. Rendering one variation is a single call:

const job = await createRender('product-demo-v1', {
  product_name: 'Premium Noise-Canceling Headphones',
  product_image: 'https://cdn.example.com/headphones-sku-42.jpg',
  price: '$149',
});
// { id: 'job_xyz', status: 'pending' }

One template, unlimited variations, zero per-video setup.

Bulk generation: batch, don't blast

Naive for…await is the first mistake. It turns a 20-minute run into 3 hours. Naive Promise.all is the second: one rejection kills 999 good renders. Bounded batches of Promise.allSettled avoid both:

async function generateInBatches(items, templateId, batchSize = 50) {
  const results = { succeeded: [], failed: [] };

  for (let i = 0; i < items.length; i += batchSize) {
    const batch = items.slice(i, i + batchSize);
    console.log(`Batch ${i / batchSize + 1}${batch.length} videos`);

    const settled = await Promise.allSettled(
      batch.map(p => createRender(templateId, {
        product_name: p.name,
        product_image: p.imageUrl,
        price: p.price,
      }))
    );

    for (const r of settled) {
      if (r.status === 'fulfilled') results.succeeded.push(r.value);
      else results.failed.push({ reason: r.reason.message });
    }

    // breathe between batches to stay under rate limits
    if (i + batchSize < items.length) await new Promise(r => setTimeout(r, 2000));
  }
  return results;
}

Throughput is rarely the bottleneck. Hosted template APIs handle 10k to 100k+ renders a month. Your error strategy matters more than how fast you submit.

Tracking completion: webhooks over polling

Polling works for a handful of jobs. In production, register a webhook and let the API tell you when a render lands. Don't skip signature verification. It's one createHmac call standing between your endpoint and spoofed events:

import crypto from 'crypto';

app.post('/webhook/render-complete', express.json(), (req, res) => {
  const expected = 'sha256=' + crypto
    .createHmac('sha256', process.env.WEBHOOK_SECRET)
    .update(JSON.stringify(req.body))
    .digest('hex');

  if (req.headers['x-renderly-signature'] !== expected) {
    return res.status(401).json({ error: 'Invalid signature' });
  }

  const { jobId, status, outputUrl, error } = req.body;
  if (status === 'completed') console.log(`✅ ${jobId}: ${outputUrl}`);
  else if (status === 'failed') console.error(`❌ ${jobId}: ${error}`);

  res.json({ received: true });
});

The full script

Loads data, retries with exponential backoff, batches, reports:

// generate-bulk-videos.js
import 'dotenv/config';

const API = 'https://renderly.video/api/v1';
const KEY = process.env.RENDERLY_API_KEY;
const TEMPLATE_ID = 'product-demo-v1';
const BATCH_SIZE = 50;

async function createRender(replacements) {
  const res = await fetch(`${API}/renders`, {
    method: 'POST',
    headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
    body: JSON.stringify({ templateId: TEMPLATE_ID, replacements }),
  });
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  return res.json();
}

async function withRetry(replacements, attempt = 0) {
  try {
    return await createRender(replacements);
  } catch (err) {
    if (attempt >= 3) throw err;
    await new Promise(r => setTimeout(r, Math.min(1000 * 2 ** attempt, 30_000))); // 1s,2s,4s
    return withRetry(replacements, attempt + 1);
  }
}

async function run() {
  // swap for your real source: DB query, CSV, upstream API
  const products = Array.from({ length: 1000 }, (_, i) => ({
    name: `Product ${i + 1}`,
    imageUrl: `https://cdn.example.com/products/product-${i + 1}.jpg`,
    price: `$${(10 + i * 0.5).toFixed(2)}`,
  }));

  let succeeded = 0, failed = 0;
  for (let i = 0; i < products.length; i += BATCH_SIZE) {
    const batch = products.slice(i, i + BATCH_SIZE);
    const settled = await Promise.allSettled(
      batch.map(p => withRetry({ product_name: p.name, product_image: p.imageUrl, price: p.price }))
    );
    succeeded += settled.filter(r => r.status === 'fulfilled').length;
    failed += settled.filter(r => r.status === 'rejected').length;
    if (i + BATCH_SIZE < products.length) await new Promise(r => setTimeout(r, 2000));
  }
  console.log(`Done: ${succeeded} queued, ${failed} failed`);
}

run().catch(console.error);

Error codes worth handling explicitly

  • 401 invalid or expired API key
  • 402 credits exhausted. Check your balance before a big run, since it's a 402 and not a generic 500
  • 404 template ID not found
  • 429 rate limited, which the backoff above already handles

Realistic numbers (from production, not marketing copy)

Scale Queue time Render completion
100 videos ~2 min ~10-15 min
1,000 videos ~15-20 min ~1-2 hours
10,000 videos ~2-3 hours ~12-24 hours

Queueing is fast. Rendering happens server-side and concurrently, so wall-clock time tracks template complexity and resolution more than your submission speed. Lean templates (fewer overlays, compressed assets, shorter durations) are the single biggest throughput lever. If 10k jobs start hitting time limits, look at the template before you touch the code.

Three pitfalls that bite at scale

  1. Sequential await instead of Promise.allSettled. This is the 20-minute run that quietly becomes a 3-hour one.
  2. No retry tracking. Persist failed job IDs to a list or table for a second pass. Log-and-forget loses those renders for good.
  3. Missing replacements defaults. An absent key falls back to the overlay's template default, so populate defaults in the template JSON.

Wrap-up

The pipeline above does 1,000 personalized videos in roughly 15 to 20 minutes of queue time, and it scales linearly. 10k is just more batches. Start with 10, confirm your template renders end-to-end, then turn up the volume.

The full version with the cost breakdown and the four production approaches lives here: How to Generate 1,000+ Personalized Videos with API Automation. Or grab an API key at renderly.video.

What's your current approach to bulk media generation? Queue-based, serverless fan-out, something else? Curious what's actually working for people.