Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply best practices for creating programmatic videos with Remotion and React.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/assets.md
1---2name: assets3description: Importing images, videos, audio, and fonts into Remotion4metadata:5tags: assets, staticFile, images, fonts, public6---78# Importing assets in Remotion910## The public folder1112Place assets in the `public/` folder at your project root.1314## Using staticFile()1516You MUST use `staticFile()` to reference files from the `public/` folder:1718```tsx19import { Img, staticFile } from "remotion";2021export const MyComposition = () => {22return <Img src={staticFile("logo.png")} />;23};24```2526The function returns an encoded URL that works correctly when deploying to subdirectories.2728## Using with components2930**Images:**3132```tsx33import { Img, staticFile } from "remotion";3435<Img src={staticFile("photo.png")} />;36```3738**Videos:**3940```tsx41import { Video } from "@remotion/media";42import { staticFile } from "remotion";4344<Video src={staticFile("clip.mp4")} />;45```4647**Audio:**4849```tsx50import { Audio } from "@remotion/media";51import { staticFile } from "remotion";5253<Audio src={staticFile("music.mp3")} />;54```5556**Fonts:**5758```tsx59import { staticFile } from "remotion";6061const fontFamily = new FontFace("MyFont", `url(${staticFile("font.woff2")})`);62await fontFamily.load();63document.fonts.add(fontFamily);64```6566## Remote URLs6768Remote URLs can be used directly without `staticFile()`:6970```tsx71<Img src="https://example.com/image.png" />72<Video src="https://remotion.media/video.mp4" />73```7475## Important notes7677- Remotion components (`<Img>`, `<Video>`, `<Audio>`) ensure assets are fully loaded before rendering78- Special characters in filenames (`#`, `?`, `&`) are automatically encoded79