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]>
21 lines
1.3 KiB
Python
21 lines
1.3 KiB
Python
# 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"})
|