Skills2026年3月29日·1 分钟阅读

Remotion Rule: Assets

Remotion skill rule: Importing images, videos, audio, and fonts into Remotion. Part of the official Remotion Agent Skill for programmatic video in React.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Remotion Rule: Assets
直接安装命令
npx -y tokrepo@latest install 5e7d0f33-7ea5-4ca6-b5f7-9719a99db833 --target codex

先 dry-run 确认安装计划,再运行此命令。

TL;DR
This Remotion agent skill rule explains how to correctly import images, videos, audio, and fonts into React-based video projects.
§01

What it is

The Remotion Assets rule is a focused skill instruction for AI agents building programmatic videos with Remotion. It covers the correct patterns for importing static and dynamic media files -- images, video clips, audio tracks, and custom fonts -- into a Remotion composition.

This rule is intended for developers and AI coding agents that generate video content in React using Remotion and need reliable media import patterns.

§02

How it saves time or tokens

Without this rule, an AI agent frequently guesses import paths or uses incompatible bundler configurations, producing broken builds. The rule eliminates trial-and-error by specifying exactly which API to use (staticFile() for public assets, ES module imports for bundled assets) and which file types each approach supports.

§03

How to use

  1. Add this rule to your Remotion project as part of the agent skill configuration.
  2. When your AI agent needs to include media in a composition, it references this rule for the correct import pattern.
  3. Use staticFile('filename.mp4') for files in the public/ folder, or import statements for assets processed by the bundler.
§04

Example

import { staticFile, Video, Img, Audio } from 'remotion';

// Public folder assets
const MyComp: React.FC = () => (
  <>
    <Video src={staticFile('background.mp4')} />
    <Img src={staticFile('logo.png')} />
    <Audio src={staticFile('narration.mp3')} />
  </>
);

// Bundled import
import heroImage from './assets/hero.png';
const Hero: React.FC = () => <Img src={heroImage} />;
§05

Related on TokRepo

§06

Common pitfalls

  • Using relative file paths instead of staticFile() causes assets to fail in the rendered output even if they work in preview.
  • Large video files in the public/ folder bloat the bundle. Use external URLs or pre-signed S3 links for assets over 50 MB.
  • Forgetting to install font files or register them with @font-face leads to fallback fonts in the final render.
  • Audio files must be WAV or MP3; some codecs (like AAC in .m4a containers) are not supported by all Remotion renderers.
  • Importing assets via dynamic require() at runtime is unsupported in Remotion's Webpack config by default.

常见问题

What is the staticFile function in Remotion?+

staticFile() resolves a filename to its path in the public/ directory. It works during both preview and rendering, ensuring assets are correctly located regardless of environment. Use it for any media file you place in the public/ folder.

Can I use external URLs for video assets in Remotion?+

Yes. The Video and Audio components accept any valid URL as the src prop. External URLs avoid bundling large files but require network access during rendering, which may slow down render times or fail in offline environments.

How do I add custom fonts to a Remotion project?+

Place font files (WOFF2, TTF) in the public/ folder and register them with a @font-face CSS declaration loaded in your Root component. Then reference the font-family in your composition styles. Google Fonts can also be imported via their CSS URL.

Does this rule work with Remotion Lambda?+

Yes. The staticFile() pattern and import-based approach both work with Remotion Lambda. However, Lambda has a payload size limit, so very large assets should be hosted externally and fetched by URL rather than bundled.

What formats does Remotion support for images?+

Remotion supports PNG, JPEG, WebP, GIF, and SVG for images. SVGs can also be imported as React components for animation. Animated GIFs play as static images by default; use the Gif component from @remotion/gif for animated playback.

引用来源 (3)
🙏

来源与感谢

Created by Remotion. Licensed under MIT. remotion-dev/skills — Rule: assets

Part of the Remotion AI Skill collection on TokRepo.

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产