merge ws/video2-theora (Theora codec, ogv)
This commit is contained in:
commit
20ecf65df8
15 files changed
+3195
-2
No files matched your search
+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