ws-video2-theora: Theora speed (fused prediction + IDCT add, inlined token decode, table-driven tokens), bench lines, guide section
tools/bench.luau: a ws-video2-theora block (320x240 testsrc2 / mandelbrot, decode and decode + image()). docs/guide/video.md: an Ogg Theora section (tested snippet; inputs from the new tools/fixtures/docs_theora.py) and the formats / writers tables.
This commit is contained in:
1 parent
4dcb005180
commit
1013925a85
6 files changed
+342
-222
No files matched your search
+27
-1
@@ -179,6 +179,7 @@ Images and animated images save as videos too.
|
||||
| Destination | Video | Audio |
|
||||
|---|---|---|
|
||||
| webm | VP8 / VP9 / AV1 copied (VP8 is decode only, so the source must be WebM-compatible) | Opus / Vorbis copied |
|
||||
| ogv | Theora copied (the source must be Theora: ogv or mkv) | Vorbis / Opus copied |
|
||||
| mkv | any codec copied, else MJPEG | copied, else PCM s16 |
|
||||
| mp4, mov | H.264 / HEVC / AV1 / MJPEG / MPEG-4 copied, else MJPEG | AAC / ALAC / Opus / FLAC / MP3 copied; PCM in MOV only |
|
||||
| avi | MJPEG copied, else MJPEG encoded (`quality`) | PCM s16 |
|
||||
@@ -235,6 +236,30 @@ assert(C.register({
|
||||
assert(C.fromFourcc("SLID") == "solid" and C.canDecode("solid"))
|
||||
```
|
||||
|
||||
## Ogg Theora
|
||||
|
||||
Ogg video (`.ogv`, or `.ogg` with a Theora stream) opens like any other container: the `ogv` format demuxes every
|
||||
Ogg stream, Theora video decodes bit-exactly (as libtheora / ffmpeg) in all three pixel formats (4:2:2 and 4:4:4
|
||||
chroma is averaged down to yuv420p), and a Vorbis, Opus or FLAC track becomes `v.audio`. Plain Ogg Vorbis / Opus /
|
||||
FLAC files stay audio. Theora in Matroska (`V_THEORA`) decodes too, and an Ogg Theora video remuxes to ogv or mkv
|
||||
(there is no Theora encoder).
|
||||
|
||||
```luau
|
||||
local v = assert(F.video.open(ogvBytes)) -- Theora + Vorbis
|
||||
assert(v.format == "ogv" and v.codec == "theora" and v.width == 64 and v.height == 48)
|
||||
assert(v.frameRate == 10 and v.audio ~= nil)
|
||||
local n = 0
|
||||
while v:nextFrame() do n += 1 end -- dropped frames repeat the previous picture
|
||||
assert(n == 10)
|
||||
local Theora = F.format("ogv") -- the format module: sniff / demux / open / encode
|
||||
local d = assert(Theora.demux(F.Bytes.reader(ogvBytes)))
|
||||
local vt = d:track("video")
|
||||
assert(vt.codec == "theora" and vt.timescale == 10) -- packet times are frame numbers here
|
||||
v:reset()
|
||||
local mkv = assert(F.save(v, nil, { format = "mkv" })) -- Theora + Vorbis copied into Matroska
|
||||
assert(F.video.open(mkv).codec == "theora")
|
||||
```
|
||||
|
||||
## Playing in a game loop
|
||||
|
||||
Decode only the frames that are due, and stop when this frame's time budget is used up; a slow frame then makes
|
||||
@@ -279,7 +304,8 @@ editable:WritePixelsBuffer(Vector2.zero, editable.Size, v:toRGBA(frame).pixels)
|
||||
| Format | Read | Write | Video codecs (decode) |
|
||||
|---|---|---|---|
|
||||
| mp4 / mov / m4v / 3gp | yes | yes | H.264, MJPEG, MPEG-1 |
|
||||
| mkv / webm | yes | yes | VP8, MJPEG, MPEG-1, raw (+ H.264) |
|
||||
| mkv / webm | yes | yes | VP8, MJPEG, MPEG-1, raw, Theora (+ H.264) |
|
||||
| ogv (Ogg Theora) | yes | yes (Theora + Vorbis / Opus copied) | Theora |
|
||||
| avi | yes | yes | MJPEG, MPEG-1, raw (+ H.264) |
|
||||
| mpegts, mpegps | yes | - | MPEG-1, H.264 |
|
||||
| y4m | yes | yes | raw |
|
||||
|
||||
Reference in new issue
Block a user