diff --git a/README.md b/README.md index 32288cf..820e275 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,43 @@ OpenMotion is a high-performance, open-source alternative to Remotion. It allows - 📹 **Offthread Video**: High-performance video decoding moved to background processes. - 📊 **Dynamic Metadata**: Calculate video dimensions, duration, and other properties dynamically based on input props. - 🎬 **GIF & Video Output**: Render to both MP4 video and GIF formats with automatic format detection. -- 🛡️ **Pre-Flight Checks**: Built-in validation and helpful error messages for missing dependencies. -- 🌍 **Custom Chromium Path**: Override the Chromium executable path using the `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH` environment variable. +### 4. 渲染视频 (正式出片) -### Dynamic Metadata +推荐使用项目自带的 `render` 脚本进行渲染,它会自动完成 **构建 -> 启动静态服务 -> 渲染 -> 自动清理** 的全套流程,确保渲染过程极其稳健,不会因开发服务器缓冲区问题而卡死。 + +```bash +# 执行一键渲染 (默认输出 ./out.mp4,开启 4 线程并行) +npm run render + +# 修改输出文件名或指定合成 ID (通过 -- 透传参数) +npm run render -- -o my-video.mp4 -c main +``` + +## 💡 最佳实践 + +### 稳健渲染方案 +生产环境建议始终优先使用 `npm run render`。该命令内部使用了静态服务模式,彻底告别渲染卡死。 + +### 参数透传技巧 +你可以通过 `npm run render -- [更多参数]` 覆盖脚本中的默认值: +- **修改并发数**: `npm run render -- -j 8` +- **指定 Chromium 路径**: `npm run render -- --chromium-path "/path/to/chrome"` + +### 资源存放 +所有本地图片/视频资源请放在 `public/` 目录下,在代码中通过 `/filename` 路径引用。 + +## 🎬 输出格式支持 +- **.mp4**: 标准视频,包含音频。 +- **.webm**: 支持透明背景的高质量视频。 +- **.gif**: 动态图片,不含音频。 +- **.webp**: 现代动图格式,体积更小,质量更好。 + +## 🛡️ 特色功能 +- 🛡️ **Pre-Flight Checks**: 内置浏览器安装检查与环境验证。 +- 🌍 **Custom Chromium Path**: 支持通过 `--chromium-path` 参数自定义浏览器路径。 +- 🚀 **Turbo Render**: 一键自动化构建与全自动渲染链条。 + +## 📚 API Reference Calculate video properties dynamically: diff --git a/packages/cli/package.json b/packages/cli/package.json index 080ac28..8c2a879 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@open-motion/cli", - "version": "0.1.1", + "version": "0.1.3", "bin": { "open-motion": "dist/bin.js" }, diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index ee28939..d2bf99a 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -32,7 +32,8 @@ export const runInit = async (projectName: string) => { dev: 'vite', build: 'vite build', preview: 'vite preview', - render: 'open-motion render -u http://localhost:5173 -o out.mp4' + render: 'npm run build && (npx http-server dist -p 5173 > /dev/null 2>&1 & sleep 2 && open-motion render -u http://localhost:5173 --composition main -o ./out.mp4 --concurrency 4 && pkill -f http-server)', + 'render:path': 'npm run build && (npx http-server dist -p 5173 > /dev/null 2>&1 & sleep 2 && PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH="/root/.cache/ms-playwright/chromium-1187/chrome-linux/chrome" open-motion render -u http://localhost:5173 --composition main -o ./out.mp4 --concurrency 4 && pkill -f http-server)' }, dependencies: { 'react': '^18.2.0', diff --git a/packages/core/package.json b/packages/core/package.json index fca3efe..6cd7375 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@open-motion/core", - "version": "0.1.1", + "version": "0.1.3", "main": "dist/index.js", "types": "dist/index.d.ts", "license": "MIT", diff --git a/packages/encoder/package.json b/packages/encoder/package.json index 8ece2cd..3c6ce4e 100644 --- a/packages/encoder/package.json +++ b/packages/encoder/package.json @@ -1,6 +1,6 @@ { "name": "@open-motion/encoder", - "version": "0.1.1", + "version": "0.1.3", "main": "dist/index.js", "types": "dist/index.d.ts", "license": "MIT", diff --git a/packages/renderer/package.json b/packages/renderer/package.json index c6cbf02..1ab2da2 100644 --- a/packages/renderer/package.json +++ b/packages/renderer/package.json @@ -1,6 +1,6 @@ { "name": "@open-motion/renderer", - "version": "0.1.1", + "version": "0.1.3", "main": "dist/index.js", "types": "dist/index.d.ts", "license": "MIT",