merge ws/video2-theora (Theora codec, ogv)
This commit is contained in:
commit
77479b6a2f
15 files changed
+3195
-2
No files matched your search
@@ -33,6 +33,7 @@ is tested under both runtimes (luau `--codegen -O2` and LuaJIT through the build
|
||||
| video | mp4 | .mp4 .m4v .mov .qt .3gp .3g2 .mj2 | yes | yes | streaming: true, remux: true, video: "mjpeg", "mpeg1", "mpeg2", "h264", audio: true, fragments: true | `tests/video/mp4.luau` |
|
||||
| video | mpegps | .mpg .mpeg .vob .m1v .mpv .dat | yes | - | streaming: true, video: "mpeg1", "mpeg2", audio: true | `tests/video/mpegps.luau` |
|
||||
| video | mpegts | .ts .m2ts .mts .tsv | yes | - | streaming: true, video: "mpeg1", "mpeg2", "h264", audio: true | `tests/video/mpegts.luau` |
|
||||
| video | ogv | .ogv .ogg | yes | yes | streaming: true, remux: true, video: "theora", audio: true | `tests/video/ogv.luau` |
|
||||
| video | y4m | .y4m | yes | yes | streaming: true, video: "rawvideo", depths: 8, 10, 12, 16 | `tests/video/y4m.luau` |
|
||||
| model | 3mf | .3mf | yes | yes | materials: true, vertexColors: true, textures: true, units: true | `tests/model/3mf.luau` |
|
||||
| model | dae | .dae .zae | yes | yes | materials: true, polygons: true, skins: true, morphTargets: true, animation: true, cameras: true, lights: true, zae: true | `tests/model/dae.luau` |
|
||||
@@ -136,4 +137,5 @@ Codecs (layer 3, shared by formats; not loadable on their own), by domain:
|
||||
- codecs/video/H264: an H.264 / AVC (ITU-T H.264 | ISO/IEC 14496-10) video decoder in pure Luau. A codec (layer 1): the
|
||||
- codecs/video/Mpeg1: the MPEG-1 video decoder (ISO/IEC 11172-2), which is codecs/video/Mpeg2 (an MPEG-2 decoder
|
||||
- codecs/video/Mpeg2: an MPEG-1 / MPEG-2 video decoder (ISO/IEC 11172-2, ISO/IEC 13818-2 Main profile).
|
||||
- codecs/video/Theora: a Theora video decoder (the Theora I specification, Xiph.Org), for Ogg (video/ogv) and Matroska
|
||||
- codecs/video/Video: the video codec registry and the generic VideoDecoder. New in formats-luau.
|
||||
+27
-1
@@ -183,6 +183,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 |
|
||||
@@ -287,6 +288,30 @@ Interlaced frames come out woven, as they were coded: deinterlace them yourself
|
||||
lines of the same field. A 720x576 interlaced stream decodes at about 130 frames per second in Luau on one desktop
|
||||
core (`tools/bench.luau`): real time with room to spare on a PC, less so on phones.
|
||||
|
||||
## 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
|
||||
@@ -331,7 +356,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, MPEG-2 |
|
||||
| mkv / webm | yes | yes | VP8, MJPEG, MPEG-1, MPEG-2, raw (+ H.264) |
|
||||
| mkv / webm | yes | yes | VP8, MJPEG, MPEG-1, MPEG-2, raw, Theora (+ H.264) |
|
||||
| ogv (Ogg Theora) | yes | yes (Theora + Vorbis / Opus copied) | Theora |
|
||||
| avi | yes | yes | MJPEG, MPEG-1, MPEG-2, raw (+ H.264) |
|
||||
| mpegts, mpegps | yes | - | MPEG-1, MPEG-2, H.264 |
|
||||
| y4m | yes | yes | raw |
|
||||
|
||||
Reference in new issue
Block a user