VR-MEDIA / scripts /ALPHA-PACK.md
Zero124's picture
VR Media Server 2.0 — latest build (custom Blomp thumbnail auto-detection + full pipeline)
5c0175e
|
Raw History Blame Contribute Delete
3.89 kB
# DeoVR Alpha Packer (`scripts/alpha-pack.mjs`)
Bakes passthrough transparency **into** your videos, the way SLR / WankzVR
author theirs. Once a file is packed and named `*_ALPHA.mp4`, DeoVR shows a
passthrough toggle that **auto-enables on launch** — the background is removed
correctly because the alpha matte is now part of the file.
## Why this is the only reliable fix
- A self-hosted DeoVR feed has **no JSON field** to auto-set a chroma color, so
in-headset chroma-key always needs manual, per-video setup and keys grey/
neutral backgrounds poorly.
- **Alpha passthrough** embeds the transparency in the video; DeoVR auto-detects
it from the `_ALPHA` filename + fisheye projection and it looks far better.
- You cannot add alpha by renaming or via the feed — the pixels must be
rewritten. That's what this script does with ffmpeg.
## Requirements
- `ffmpeg` + `ffprobe` (already on the HF Space image and the sandbox).
- **Source must be FISHEYE.** DeoVR alpha only works on fisheye meshes
(180 / 190 / 200-MKX / 220-VRCA). Equirectangular/flat sources are skipped
with a warning — use `--from-equirect` (experimental) or convert first
(https://deovr.com/blog/123).
## Formats it understands (auto-detected from the filename)
DeoVR reads projection + stereo from the filename, so the packer **detects and
preserves** those tokens and just inserts `_ALPHA`:
| Kind | Tokens it recognizes |
|------|----------------------|
| Fisheye FOV | `fisheye`, `fisheye190` / `fish190`, `mkx200` (or `200`), `vrca220` (or `220`), `rf52`, bare `180/190/200/220` |
| Stereo | `SBS` / `LR` / `3DH` (side-by-side), `TB` / `OU` / `3DV` (top-bottom), `MONO` / `2D` |
Examples:
```
Clip_FISH190_SBS.mp4 -> Clip_FISH190_SBS_ALPHA.mp4
Clip_mkx200_TB.mp4 -> Clip_mkx200_TB_ALPHA.mp4 (auto horizontal pack)
plain_fisheye.mp4 -> plain_fisheye_ALPHA.mp4
```
If a source has no fisheye/stereo token, add one to the output name with
`--projection fisheye190` and/or `--stereo-tag SBS`.
## Quick start
```bash
# One file (grey screen, already fisheye):
node scripts/alpha-pack.mjs --input Clip_FISH190_SBS.mp4 --color grey
# Green screen:
node scripts/alpha-pack.mjs -i Clip_mkx200_SBS.mp4 -c green
# A whole folder of mixed fisheye formats (each keeps its own tokens):
node scripts/alpha-pack.mjs --input-dir /data/masters -c grey --output-dir /data/out
# Straight from an Offcloud stream URL:
node scripts/alpha-pack.mjs -i "https://.../stream.mp4" -c grey -o /data/clip_ALPHA.mp4
```
Run `node scripts/alpha-pack.mjs --help` for every flag.
## Getting the pack layout right (READ IF PASSTHROUGH DOESN'T AUTO-KEY)
DeoVR expects the color image and the alpha matte packed in a specific
arrangement. Ground-truth references: DeoVR's **Deo-Alpha-Packer.exe**
(https://deovr.com/blog/59) and the community ffmpeg batch script
(https://forum.deovr.com/d/9993).
Defaults: **vertical** (color top / alpha bottom) for SBS & mono, **horizontal**
(color left / alpha right) for TB. If DeoVR doesn't auto-key, try in order until
it matches what worked for you before:
1. `--layout vertical`
2. `--layout vertical --alpha-first`
3. `--layout horizontal`
4. `--layout horizontal --alpha-first`
## Keying tips
- **auto** keyer picks `chromakey` for colored screens and `colorkey` for grey/
black/white (they have no hue, so hue-based chromakey fails on them).
- Raise `--similarity` to remove more of the background; raise `--blend` for
softer edges. For a stubborn grey, try `--keyer lumakey` with
`--luma-threshold` / `--luma-tolerance`.
## After packing
Host the `_ALPHA` files (re-upload to Offcloud or serve them). Transparency
can't be added on the fly while streaming — it's written into the file once,
then DeoVR handles passthrough automatically.