Open-Source LLMs vs Closed Models: AI Video Generation via Web Frontend Rendering
This article examines the practical gap between Chinese open-source LLMs and leading closed-source models, then presents a hands-on AI video generation workflow. It covers environment setup, safe dependency cleanup, prompt-driven generation of HTML/CSS/JS animation code, headless-browser frame rendering, MP4 export, and frame-level validation, including solutions for animation timing and screenshot synchronization.
In recent years, open-source LLMs developed in China have advanced rapidly, with trillion-parameter models being released. In real-world use, however, open-source models still lag behind leading closed-source LLMs in core capabilities such as code generation, long-context understanding, and complex tool calling. This does not mean they cannot support engineering work in specific scenarios. This article uses a practical AI video generation case to explore how Chinese open-source LLMs, combined with web frontend technologies, can generate high-quality video efficiently.
1. Developer Video Production Pain Points and the Evolution of Technical Approaches
For product developers and enterprise teams, video production—such as product launch videos, data growth animations, and captioned talking-head clips—is unavoidable. Traditionally, using professional editing software to align timelines frame by frame is time-consuming and labor-intensive. Asking AI to directly generate code for a specific frontend framework, such as a React-based video rendering library, requires configuring complex dependency environments; once the code logic becomes complex, errors are highly likely.
To address this, a simpler approach has emerged: have the LLM write ordinary web code (HTML/CSS/JS), then render it frame by frame through a headless browser and export it as MP4. This greatly reduces the difficulty of code generation and improves rendering stability, making it an effective path for AI video generation today.
2. Environment Setup and Security Configuration
Before generating video, ensure the local environment has Node.js, npm, and a Chrome headless browser rendering setup. Developers can use common intelligent coding tools to manage local environment configuration.
The first step is to send a prompt to the model to check and install the basic rendering environment, and initialize a web video rendering project in a specified directory. When cleaning historical dependency caches, developers should pay special attention to security interception mechanisms. For example, when the system detects a batch deletion operation (such as deleting the node_modules directory) and triggers a “high-risk command” warning, review the pop-up prompt carefully. If the deletion targets a dependency cache directory, it can be allowed; if it involves other system files, it must be rejected. After initialization, run the built-in basic test clip for headless rendering validation. This self-check usually takes tens of seconds, indicating that the underlying rendering pipeline is ready.
3. Generating Video Code with an Open-Source Model
Once the environment is ready, the core code generation stage begins. Using a Chinese open-source LLM as an example, we set its role as a frontend video development expert. The goal is to extract the real interface, color scheme, and copy from a specific webpage and generate a roughly 20-second, 9:16 vertical product launch video.
Through a precise prompt, the model is asked to include shot transitions, text fade-in/fade-out effects, and a closing logo in the generated HTML/CSS/JS code. The open-source LLM showed good code structuring capability here. It can break visual animations into CSS keyframe animations and control the timeline through JavaScript to ensure all animations complete within the specified duration.
// Illustrative code: control keyframes and timeline via JSfunction renderFrame(frameIndex, totalFrames) {const fps = 30;const currentTime = frameIndex / fps;if (currentTime < 5) {showScene1(); // Scene 1: logo fade-in and title display} else if (currentTime < 15) {showScene2(); // Scene 2: core feature data growth animation} else {showScene3(); // Scene 3: closing logo and brand ending}if (frameIndex < totalFrames) {requestAnimationFrame(() => renderFrame(frameIndex + 1, totalFrames));}}
4. Headless Browser Rendering and Frame Validation
After code generation, the most critical step is to verify whether the web-rendered video has dropped frames or screen tearing. This can be checked by comparing a screenshot of a specific frame from the headless browser with the corresponding frame in the final exported MP4.
For example, extract frame 150: the left side is the frame captured directly by the headless browser, and the right side is the MP4 exported through the rendering pipeline, paused at frame 150 in a player. If the visual elements in both images are completely consistent, the rendering pipeline is working normally without dropped frames.
During this process, developers may encounter unsynchronized animation execution. This is usually because the CSS animation execution timing is not aligned with the headless browser’s screenshot timing. The solution is to introduce precise requestAnimationFrame control in the code and notify the headless browser to take a screenshot via a callback after each frame is rendered, ensuring complete frame capture. For complex DOM structures, it is also advisable to add an appropriate delay before screenshots to ensure the browser has finished repainting.
5. Conclusion
Although open-source models still have a gap with leading closed-source models in general intelligence and complex logical reasoning, in scenarios combined with specific toolchains—such as web frontend rendering frameworks—Chinese open-source LLMs can already handle high-quality code generation tasks. By turning complex video editing into standard frontend code writing, developers not only improve content production efficiency but also provide a new technical paradigm for AI-enabled business scenarios. As open-source models continue to iterate in code generation and tool-calling capabilities, they will play a core role in more vertical engineering scenarios.
