Skip to main content

staticFile() 不支持相对路径

如果你收到以下错误信息:

🌐 If you got the following error message:

staticFile() does not support relative paths. Instead, pass the name of a file that is inside the public/ folder.

你尝试将相对路径传递给 staticFile()

🌐 You have tried to pass a relative path to staticFile():

❌ Relative path
import { staticFile } from "remotion"; staticFile("../public/image.png");
❌ File should not have ./ prefix
import { staticFile } from "remotion"; staticFile("./image.png");

或者你试图传递一个绝对路径:

🌐 Or you tried to pass an absolute path:

❌ File should not use absolute paths
import { staticFile } from "remotion"; staticFile("/Users/bob/remotion-project/public/image.png");

或者你试图添加一个 public/ 修复,这是不必要的:

🌐 Or you tried to add a public/ fix which is unnecessary:

❌ File should not include the public/ prefix
import { staticFile } from "remotion"; staticFile("public/image.png");

相反,直接传入位于 public 文件夹中的文件名:

🌐 Instead, pass the name of the file that is inside the public folder directly:

✅ Filename
import { staticFile } from "remotion"; staticFile("image.png");

另请参阅

🌐 See also