All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 5m13s
新增 tools/asset-pipeline/ 用于把 public/portraits & videos 压缩成桶友好体积: - sharp: PNG → WebP q82, 最大宽 1600 (-view 三视图 2400) - ffmpeg: MP4 → libx264 CRF 28, 最大宽 1920, AAC 96k, faststart - pack.mjs: tar -czf 整目录 → cyber-star-assets.tar.gz 效果 (146 portraits + 33 videos): - 立绘: 768.6MB → 26.8MB (-96%) - 视频: 251.7MB → 76.1MB (-70%) - 总计: 1020MB → 103MB 压缩到 1/10, 95s 跑完 输出位于仓库外 ../assets-compressed/ 与 ../cyber-star-assets.tar.gz, 不入 git。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
1.4 KiB
Markdown
52 lines
1.4 KiB
Markdown
# Asset Pipeline · TOS 桶资源压缩 + 打包
|
||
|
||
把 `public/portraits/` 和 `public/videos/` 转成桶友好的体积(WebP + H.264),输出到仓库外的 `../assets-compressed/`。
|
||
|
||
## 输出结构(与桶目录对齐)
|
||
|
||
```
|
||
assets-compressed/
|
||
├── portraits/
|
||
│ ├── 001.webp
|
||
│ ├── 001-2.webp
|
||
│ ├── 001-3.webp
|
||
│ ├── 001-view.webp
|
||
│ └── ...
|
||
└── videos/
|
||
├── hero-pv.mp4
|
||
└── artists/001.mp4 ...
|
||
```
|
||
|
||
## 压缩参数
|
||
|
||
| 类型 | 处理 | 目标体积 |
|
||
|---|---|---|
|
||
| 立绘 / 氛围图 PNG | WebP q82, 最大宽 1600 | ≤ 800KB |
|
||
| 三视图 `-view.png` | WebP q82, 最大宽 2400 | ≤ 1.5MB |
|
||
| 视频 MP4 | libx264 CRF 28, 最大宽 1920, AAC 96k, faststart | 单条 ≤ 3MB / Hero PV ≤ 15MB |
|
||
|
||
## 用法
|
||
|
||
```bash
|
||
cd tools/asset-pipeline
|
||
npm install # 装 sharp + ffmpeg-installer (各自带二进制, 无需系统装)
|
||
npm run compress # 压缩, 已存在且新于源的输出会跳过 (可恢复中断)
|
||
npm run pack # 打包成 cyber-star-assets.tar.gz
|
||
```
|
||
|
||
输出文件:
|
||
|
||
```
|
||
../../assets-compressed/ # 压缩后的源文件 (供回滚 / 抽查)
|
||
../../cyber-star-assets.tar.gz # 发给运维上传的最终包
|
||
```
|
||
|
||
## 上传到桶
|
||
|
||
运维拿到 `cyber-star-assets.tar.gz` 解压后,用 tosutil 整目录推:
|
||
|
||
```bash
|
||
tar -xzf cyber-star-assets.tar.gz
|
||
tosutil cp -r -f assets-compressed/* tos://cyber-star/
|
||
```
|