docs: legacy video (guide section, formats table rows, docs/video.md layers row); docs_legacy inputs
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
53325af777
commit
cce0d17209
3 files changed
+105
No files matched your search
@@ -288,6 +288,77 @@ editable:WritePixelsBuffer(Vector2.zero, editable.Size, v:toRGBA(frame).pixels)
|
||||
|
||||
See [FORMATS.md](../FORMATS.md). Subtitle tracks of Matroska files are read as cues by `F.format("mkv").subtitles`.
|
||||
|
||||
<!-- ws-video2-legacy: formats table addition -->
|
||||
| fli / flc / flx | yes | - | FLIC (8-bit palettised, 15 / 16 / 24-bit) |
|
||||
| smk | yes | - | Smacker video (SMK2 / SMK4) + Smacker audio / PCM |
|
||||
|
||||
AVI, MOV / MP4 and MKV (V_MS/VFW/FOURCC, V_QUICKTIME) also decode the legacy codecs: Cinepak, Microsoft Video 1,
|
||||
QuickTime Animation (RLE) and QuickTime Graphics (SMC). See [Legacy video](#legacy-video).
|
||||
|
||||
<!-- ws-video2-legacy: section -->
|
||||
## Legacy video
|
||||
|
||||
The 1990s formats and codecs decode to **rgba8** frames (they are palettised or RGB, not YUV), each frame painted
|
||||
over the previous one, as the codecs define. Decoding is bit-exact with ffmpeg's.
|
||||
|
||||
| Codec id | Name | Containers | Depths |
|
||||
|---|---|---|---|
|
||||
| `flic` | Autodesk FLI / FLC | fli | 8-bit palettised, 15 / 16 / 24-bit |
|
||||
| `smackvid` | Smacker video | smk | 8-bit palettised |
|
||||
| `cinepak` | Cinepak (`cvid`) | avi, mov, mkv | 24-bit, grey, 8-bit palettised |
|
||||
| `msvideo1` | Microsoft Video 1 (`CRAM`, `MSVC`, `WHAM`) | avi, mov, mkv | 16-bit (5-5-5), 8-bit palettised |
|
||||
| `qtrle` | QuickTime Animation (`rle `) | mov, mkv | 1, 2, 4, 8 (palettised or grey), 16, 24, 32 (alpha) |
|
||||
| `smc` | QuickTime Graphics (`smc `) | mov, mkv | 8-bit palettised |
|
||||
|
||||
Palettes come from the container: `track.palette` (256 entries, 4 bytes each: R, G, B, A) holds the AVI
|
||||
BITMAPINFO palette or the QuickTime colour table (or the Macintosh default table it refers to); FLIC and Smacker
|
||||
frames carry their own palette changes.
|
||||
|
||||
```luau
|
||||
local v = assert(F.video.open(cinepakBytes)) -- Cinepak in a QuickTime movie
|
||||
assert(v.format == "mov" and v.codec == "cinepak")
|
||||
local frames = 0
|
||||
while true do
|
||||
local f = v:nextFrame()
|
||||
if not f then break end
|
||||
assert(f.image.format == "rgba8" and f.image.width == 64)
|
||||
frames += 1
|
||||
end
|
||||
assert(frames == v.frames)
|
||||
```
|
||||
|
||||
FLIC files (`.fli` at 70 Hz ticks, `.flc` / `.flx` in milliseconds) open as videos; the ring frame (an extra frame
|
||||
leading back to the first, for looping) is not shown unless you ask for it.
|
||||
|
||||
```luau
|
||||
local v = assert(F.video.open(flcBytes))
|
||||
print(v.format, v.codec, v.width, v.height, v.frameRate) -- fli flic 64 48 10
|
||||
assert(v.track.bitsPerPixel == 8 and v.frames == 10)
|
||||
local f = assert(v:nextFrame())
|
||||
local r, g, b, a = F.ops.image.getPixel(f.image, 0, 0) -- palette colours, opaque
|
||||
assert(r and g and b and a == 255)
|
||||
local all = assert(F.format("fli").open(F.Bytes.reader(flcBytes), { ringFrame = true }))
|
||||
assert(all.codec == "flic")
|
||||
```
|
||||
|
||||
Smacker files carry up to seven audio tracks. The format decodes Smacker's packed audio (and raw PCM tracks) itself:
|
||||
`v.audio` is the first track, `F.format("smk").openAudio(demuxer, track)` opens any of them.
|
||||
|
||||
```luau
|
||||
local v = assert(F.video.open(smkBytes))
|
||||
assert(v.format == "smk" and v.codec == "smackvid")
|
||||
local a = assert(v.audio, tostring(v.audioError)) -- packed 16-bit stereo, 22050 Hz
|
||||
assert(a.sampleRate == 22050 and a.channels == 2)
|
||||
local Smk = F.format("smk")
|
||||
for _, t in v.demuxer.tracks do
|
||||
if t.kind == "audio" then
|
||||
local dec = assert(Smk.openAudio(v.demuxer, t)) -- smackaudio, pcm_u8 or pcm_s16le
|
||||
local pcm, n = dec:read(1000)
|
||||
assert(n == 1000 and buffer.len(pcm) == n * dec.channels * 4)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
## Gotchas
|
||||
|
||||
- Pure-Luau decoding is CPU-bound: H.264 and VP8 are practical at low resolutions. Measure with `tools/bench.luau`
|
||||
|
||||
@@ -28,6 +28,7 @@ F.convert(gif, "avi") -- animated images become videos (un
|
||||
| `codecs/video/Video/Source` | what writers write: copied packets or frames encoded by a registry encoder, PCM from the audio |
|
||||
| `codecs/image/Yuv` | yuv420p <-> rgba8 (BT.601 / 709, limited / full range from `image.meta.yuv`), range remap |
|
||||
| `codecs/image/Vp8`, `Jpeg`, `Mpeg1` | the decoders (and the JPEG encoder) |
|
||||
| `codecs/video/Legacy` | FLIC, Smacker, Cinepak, Microsoft Video 1, QuickTime RLE / SMC: rgba8, palettes from `track.palette` |
|
||||
| `video/<fmt>` | the formats: demux into `containers/Demux`, `open` = `Video.open(demuxer, opts)`, `encode` via Source |
|
||||
|
||||
Audio tracks reach the audio formats through the api hook `opts.openAudio(demuxer, track)` (a format never requires
|
||||
|
||||
Reference in new issue
Block a user