Building an LLM-Driven Procedural Video Generation Workflow: From Prompt Design to Reproducible Delivery
A practical methodology for using large language models to generate short videos entirely through code—no external assets, no generative media APIs. This article covers how to define hard constraints, choose the right technical stack (WebGL shaders vs. Python frame-by-frame rendering), design effective prompts, and evaluate output quality across reproducibility, performance, and narrative structure.
Building an LLM-Driven Procedural Video Generation Workflow: From Prompt Design to Reproducible Delivery
Background and Problem Definition
As large language models grow more capable of writing code, an interesting creative trend has emerged: generating a complete short video purely through code, without using any external assets. Every frame in this kind of work can be produced by mathematical functions, fractal algorithms, particle systems, or shader rendering, and audio can be generated through synthesis algorithms. The entire process depends on no images, videos, or generative multimedia APIs.
This kind of task is a comprehensive test of model capability. It requires the model to understand visual aesthetics and narrative pacing, have solid graphics programming fundamentals, and output well-structured, directly runnable project code. Many developers design a unified “baseline prompt” to benchmark different models. Using this scenario as a thread, this article breaks down a complete methodology.
Analyzing the Core Constraints
When designing this type of task, hard constraints should be defined first so that model performance can be compared fairly:
- Pure code generation: Any text-to-image, text-to-video, or generative audio API is forbidden. All visual and auditory elements must be produced by algorithms.
- Reproducibility: The output must include complete source code, dependency instructions, and run/export commands, so a third party can reproduce the result with a single command.
- Real output: Pseudocode or “illustrative mockups” don’t count. Actual frame sequences or video files must be exported.
- Technical depth: At least one relatively complex technique must be included, such as procedural materials, lighting and shadows, fluid approximation, fractals, post-processing, or audio-driven visuals.
- Narrative structure: The work should have a clear beginning, development, and resolution, with deliberate camera work, color, and composition rather than pure technical showing off.
These constraints are tightly interlocked. Reproducibility is the engineering baseline, technical depth reflects the capability ceiling, and narrative structure is the aesthetic threshold. If any one of them is missing, the overall quality drops noticeably.
Technology Choices and Implementation Paths
Browser-Based: Canvas / WebGL / Shaders
This is currently the easiest approach to reproduce. Writing shaders in WebGL or WebGPU allows efficient implementation of procedural noise, fractals, ray marching, and other complex effects. Combined with JavaScript off-screen per-frame rendering, image frame sequences can be exported.
A typical fractal noise shader snippet:
float fbm(vec2 p) {float value = 0.0;float amplitude = 0.5;for (int i = 0; i < 6; i++) {value += amplitude * noise(p);p *= 2.0;amplitude *= 0.5;}return value;}
Passing a time parameter into the shader produces continuously evolving motion. Combined with pulse noise, vortex distortion, and color mapping functions, you can construct visual concepts like nebulae, fluids, and auroras.
Python-Based: Frame-by-Frame Rendering with a Framework
If you need more fine-grained particle systems or physics simulation, Python per-frame drawing is an option, with ffmpeg handling the final video assembly:
python render.py --fps 30 --frames 900ffmpeg -framerate 30 -i frames/%05d.png -i audio.wav \-c:v libx264 -pix_fmt yuv420p output.mp4
The advantages are intuitive debugging and a mature ecosystem. The downside is lower rendering throughput than the shader approach, so performance budgets need attention.
The Driving Role of Audio Synthesis
Audio can also be synthesized procedurally—for example, ambient music generated through sine-wave layering and envelope control. Going further, you can build audio-driven visuals: mapping audio parameters (such as low-frequency energy or beat points) back onto visual color pulses or particle bursts, achieving audio-visual synchronization as an artistic effect.
Key Principles of Prompt Engineering
Getting the model to produce qualified output requires carefully designed prompts. Several key points emerged from practice:
- Role assignment: Give the model a dual identity—“creative technical director and graphics programmer”—activating both aesthetic judgment and engineering capability at once.
- Constraints up front: Place hard constraints at the beginning of the prompt to reduce the probability of unrunnable code.
- Structured deliverables: Require output in a fixed format: concept description, technical plan, code structure, run commands, path conventions, and self-assessment. Structured requirements significantly improve output completeness.
- Enforced priorities: Make explicit that “if output length is limited, prioritize a runnable core visual” to keep the model from spending space on empty descriptions.
A sample prompt outline:
You are a creative technical director and graphics programmer. Generate a30–60 second procedural short video at 1920×1080, 30fps, purely by writing code.Hard constraints: no external assets or generative multimedia APIs; all framesgenerated by code; provide a fully reproducible project with render/exportcommands; include at least one advanced graphics technique; the visuals shouldhave narrative arc and design intent; state your performance budget anddegradation plan.Deliverable format: A. Concept B. Technical plan C. Complete code D. Runcommands E. Output paths F. Self-assessment.
Evaluation Framework: How to Judge Output Quality
Once the model delivers its output, you can score it systematically across six dimensions:
- Visual impact: Does the first impression impress? Are color and motion coherent?
- Technical difficulty: Does it use fractals, particle simulation, lighting computation, or other advanced techniques?
- Code quality: Is the structure clear, are comments reasonable, are there anti-patterns?
- Reproducibility: Are dependencies and run commands complete? Does it work on the first try?
- Performance and stability: Does the frame rate hit target? Does long-duration rendering crash?
- “Pure code” authenticity: Is it truly zero-asset and zero-API-call, with no smuggled pseudocode?
This evaluation framework also applies to AI-assisted programming scenarios for assessing the delivery quality of more general engineering tasks.
Performance Budgets and Degradation Plans
A careful look reveals an interesting pattern: developers have noticed that once high-barrier features open up at more accessible subscription tiers, it usually reflects shifting compute scheduling and market strategy—but the underlying rendering capability itself stays the same. For creative work, performance planning is always unavoidable:
- Resolution budget: At 1920×1080@30fps, each frame is roughly 2.07 million pixels. Avoid excessive loop counts in shaders; keep noise sampling to about 5–8 octaves.
- Progressive degradation: Provide a
--lowflag that drops resolution to 1280×720 or halves the octave count, keeping the project runnable on lower-end devices. - Incremental rendering: Preview and tune at low resolution first, then run full-resolution offline rendering once the visual is confirmed.
- Frame cache reuse: For particle-based effects, save state files so interrupted renders can resume from a checkpoint.
Closing Thoughts
Procedural video generation is an excellent litmus test for overall LLM capability, simultaneously examining aesthetic expression, algorithmic skill, and engineering discipline. No matter which AI coding tool or cloud compute resource you use (for example, leveraging cloud GPU instances to accelerate offline rendering), what truly determines the quality ceiling is the trio of prompt design, technology selection, and evaluation criteria. This approach does not depend on any particular platform—readers can immediately set up their own testing pipeline in their own environment and build a personal AI creation workflow. That is precisely the most valuable transferable skill in this field.
