The Gap in Open-Source LLMs and a Web Rendering Video Solution: Setup, Validation, and Troubleshooting
This article explores the current gaps between open-source and top-tier closed-source large language models (LLMs) in coding, long-text comprehension, and tool invocation, while highlighting the advantages of open-source models in customized scenarios. It also introduces a web-based rendering approach for video generation, detailing environment setup, validation steps, troubleshooting tips, and core rendering code using Puppeteer and FFmpeg.
Recent releases of open-source models with up to 2.8 trillion parameters show significant progress in model scale and architecture. However, in practical engineering, a gap remains between open-source models and top-tier closed-source models, primarily in three areas.
First is code generation. Closed-source models currently achieve higher accuracy in complex engineering code generation, long-context completion, and cross-file reasoning. Second is long-text comprehension. Even with expanded context windows, the precision of information extraction from ultra-long texts and the coherence of multi-document summarization still need improvement. Third is tool invocation. AI Agents need to plan tasks, decompose API calls, and handle exception returns; the stability of this process determines the model’s practical value, where closed-source models perform more reliably.
Open-source models also have their advantages. They provide irreplaceable value in vertical domain customization, data privacy protection, and local deployment. Through engineering encapsulation and prompt optimization, open-source models can handle many complex automation tasks.
Why Use Web Rendering for Video Generation
Traditional video editing software requires manually dragging timelines, which is inefficient and difficult to automate in batches. Video generation solutions based on frameworks like React rely on heavy engineering configurations. Once animation logic becomes complex, state management and rendering errors frequently occur.
An alternative approach is to have the LLM directly write standard web pages (HTML, CSS, JS), use a headless browser to take frame-by-frame screenshots, and finally synthesize them into an MP4. HTML, CSS, and JS appear frequently in pre-training data, so models generate this type of code more accurately than specialized video scripts. The table below compares three approaches.
| Approach | Dependencies & Config | Automation Level | Debugging Difficulty | Suitable Scenarios |
|---|---|---|---|---|
| Traditional Editing Software | No programming environment | Low, relies on manual operation | Low | Single or few videos |
| React Video Framework | Heavy dependencies, requires config | Medium | Medium to High | Long-term projects with a frontend team |
| Web Page Rendering to Video | Node.js and headless browser | High | Low, can be viewed directly in browser | Batch generation, template-based videos |
Environment Setup Steps
- Install Node.js and npm, and verify the versions are available.
- Install a headless browser, such as the Chromium-based Puppeteer. During the first installation, check if the browser download is complete.
- Initialize the project in your working directory and install community rendering frameworks and their dependencies.
- Run the framework’s built-in test clip to ensure the output file plays correctly.
- Before cleaning up old dependencies, confirm the target path is inside the project directory and that
node_modulesis not a symlink pointing elsewhere. Use version control or a backup to preserve the current state, then delete using a traceable command, and save the operation logs. - If a security tool blocks batch deletion, verify the paths one by one. Reject and block any paths outside the project directory.
In the original test, rendering the framework’s 10-second test clip took 17.7 seconds. This figure represents a single run, and the original test did not list the server configuration. When reproducing, please record the machine configuration, resolution, frame rate, and rendering framework version for horizontal comparison.
Rendering Code and Key Details
The code below illustrates the core process of frame-by-frame rendering. The web page needs to expose two global interfaces: window.__ready indicates that resources and fonts are loaded, and window.renderAt(t) sets the animation state to the t-th second.
const puppeteer = require('puppeteer');const path = require('path');const fs = require('fs');const WIDTH = 1080, HEIGHT = 1920, FPS = 30, DURATION = 20;const TOTAL = FPS * DURATION;const outDir = path.resolve('frames');fs.mkdirSync(outDir, { recursive: true });(async () => {const browser = await puppeteer.launch();const page = await browser.newPage();await page.setViewport({ width: WIDTH, height: HEIGHT, deviceScaleFactor: 1 });await page.goto('file://' + path.resolve('generated/index.html'), { waitUntil: 'load' });await page.addStyleTag({ content: 'html,body{overflow:hidden}::-webkit-scrollbar{display:none}' });await page.evaluate(() => document.fonts.ready);await page.waitForFunction(() => window.__ready === true, { timeout: 15000 });for (let i = 0; i < TOTAL; i++) {await page.evaluate((t) => window.renderAt(t), i / FPS);const file = path.join(outDir, `frame_${String(i).padStart(5, '0')}.png`);await page.screenshot({ path: file });}await browser.close();})().catch((err) => { console.error(err); process.exit(1); });
Several settings in the code serve specific purposes. deviceScaleFactor: 1 ensures the screenshot resolution matches the viewport. Hiding the scrollbars prevents them from appearing in screenshots. Waiting for fonts to be ready prevents font fallback in the captured frames. Since screenshots occasionally fail due to page busyness, a production environment should implement 2 to 3 retries for single-frame captures.
When synthesizing the video, the frame rate parameter must be consistent with the rendering loop:
ffmpeg -framerate 30 -i frames/frame_%05d.png -c:v libx264 -pix_fmt yuv420p -crf 18 output.mp4
The -framerate must match the FPS used during rendering; otherwise, the video duration will deviate from the expected length. The -pix_fmt yuv420p parameter is applied for pixel format compatibility.
