34 lines
1.8 KiB
Python
34 lines
1.8 KiB
Python
# Docs inputs for the legacy video sections of docs/guide/video.md (tools/fixtures.py; tools/docs_check.py reads them):
|
|
# a 64x48 FLC (tools/fixtures/fli.py's encoder), a 64x48 SMK4 with a packed stereo and a raw mono audio track
|
|
# (tools/fixtures/smk.py's encoder) and a 64x48 Cinepak MOV from ffmpeg.
|
|
# tests/gen/docs_legacy.luau { files = { [name] = bytes }, vars = { flcBytes = "anim.flc", ... } }
|
|
import importlib.util, os, tempfile
|
|
|
|
INPUTS = ["tools/docs_check.py", "tools/fixtures/fli.py", "tools/fixtures/smk.py", "tools/fixtures/_video.py"]
|
|
|
|
|
|
def load(ctx, name):
|
|
spec = importlib.util.spec_from_file_location("docs_legacy_" + name.replace("/", "_"), os.path.join(ctx.root, "tools", name + ".py"))
|
|
m = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(m)
|
|
return m
|
|
|
|
|
|
def generate(ctx):
|
|
dc = load(ctx, "docs_check")
|
|
fli = load(ctx, "fixtures/fli")
|
|
smk = load(ctx, "fixtures/smk")
|
|
v = load(ctx, "fixtures/_video")
|
|
files = {}
|
|
w, h, n = 64, 48, 10
|
|
imgs = fli.idx_frames(w, h, n, 256, 5)
|
|
frames = [fli.frame([fli.color([(0, fli.pal(256, 5, False))], False), fli.brun([[bytes([x]) for x in r] for r in imgs[0]], 1, True)])]
|
|
frames += [fli.frame([fli.ss2(imgs[t], imgs[t - 1])]) for t in range(1, n)]
|
|
files["anim.flc"] = fli.file(0xAF12, w, h, 8, 100, frames)
|
|
files["intro.smk"] = smk.smk_file(4, 64, 48, 10, 100, [("packed", 22050, 2, 16), ("raw", 11025, 1, 8)], False, 7)
|
|
with tempfile.TemporaryDirectory() as d:
|
|
out = os.path.join(d, "cinepak.mov")
|
|
v.ffmpeg(["-f", "lavfi", "-i", "testsrc=size=64x48:rate=10:duration=1", "-c:v", "cinepak", out])
|
|
files["cinepak.mov"] = open(out, "rb").read()
|
|
dc.emit_inputs(ctx, files, {"flcBytes": "anim.flc", "smkBytes": "intro.smk", "cinepakBytes": "cinepak.mov"})
|