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. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
7dd4d54546
commit
6a8cbaa8c0
6 files changed
+342
-222
No files matched your search
@@ -0,0 +1,20 @@
|
||||
# Docs inputs for the Ogg Theora section of docs/guide/video.md (tools/fixtures.py; tools/docs_check.py reads them): a
|
||||
# tiny ffmpeg clip (testsrc 64x48, 10 frames at 10 fps, libtheora + a libvorbis sine track) as Ogg video.
|
||||
# tests/gen/docs_theora.luau { files = { ["clip.ogv"] = bytes }, vars = { ogvBytes = "clip.ogv" } }
|
||||
import importlib.util, os, shutil, subprocess, tempfile
|
||||
|
||||
INPUTS = ["tools/docs_check.py"]
|
||||
|
||||
|
||||
def generate(ctx):
|
||||
spec = importlib.util.spec_from_file_location("docs_theora_check", os.path.join(ctx.root, "tools", "docs_check.py"))
|
||||
dc = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(dc)
|
||||
ffmpeg = shutil.which("ffmpeg") or ctx.nix("ffmpeg-full", ["sh", "-c", "command -v ffmpeg"]).decode().strip()
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
out = os.path.join(d, "clip.ogv")
|
||||
subprocess.run([ffmpeg, "-v", "error", "-y", "-f", "lavfi", "-i", "testsrc=size=64x48:rate=10:duration=1",
|
||||
"-f", "lavfi", "-i", "sine=frequency=440:sample_rate=44100:duration=1", "-c:v", "libtheora",
|
||||
"-q:v", "6", "-g", "5", "-c:a", "libvorbis", "-q:a", "2", out], check=True, capture_output=True)
|
||||
files = {"clip.ogv": open(out, "rb").read()}
|
||||
dc.emit_inputs(ctx, files, {"ogvBytes": "clip.ogv"})
|
||||
@@ -10,7 +10,7 @@
|
||||
# rate, channels }
|
||||
# tests/gen/theora_opus.luau, theora_flac.luau the same with mono Opus / FLAC audio
|
||||
# tests/gen/theora_mkv.luau { file (base64 .mkv), frames }
|
||||
# tests/gen/theora_bench.luau { file (base64 .ogv, 320x240) } for tools/bench.luau
|
||||
# tests/gen/theora_bench.luau { { name, file (base64 .ogv, 320x240), width, height } } for tools/bench.luau
|
||||
import base64, os, shutil, struct, subprocess, tempfile, zlib
|
||||
|
||||
FF = ["-hide_banner", "-loglevel", "error", "-y"]
|
||||
@@ -199,7 +199,10 @@ def generate(ctx):
|
||||
ff(["-i", os.path.join(tmp, "odd.ogv"), "-c", "copy", mkv])
|
||||
ctx.emit("theora_mkv", {"file": b64(open(mkv, "rb").read()), "frames": framecrc(mkv, "yuv420p"),
|
||||
"width": 174, "height": 98})
|
||||
# the bench stream
|
||||
bench = os.path.join(tmp, "bench.ogv")
|
||||
ff(src("testsrc2", 320, 240, 25, 2) + ["-c:v", "libtheora", "-b:v", "600k", "-g", "25", bench])
|
||||
ctx.emit("theora_bench", {"file": b64(open(bench, "rb").read()), "width": 320, "height": 240})
|
||||
# the bench streams: an easy clip (testsrc2, mostly static) and a hard one (a mandelbrot zoom: every block moves)
|
||||
bench = []
|
||||
for kind, rate in (("testsrc2", "600k"), ("mandelbrot", "1200k")):
|
||||
path = os.path.join(tmp, "bench_" + kind + ".ogv")
|
||||
ff(src(kind, 320, 240, 25, 2) + ["-c:v", "libtheora", "-b:v", rate, "-g", "25", path])
|
||||
bench.append({"name": kind, "file": b64(open(path, "rb").read()), "width": 320, "height": 240})
|
||||
ctx.emit("theora_bench", bench)
|
||||
Reference in new issue
Block a user