Files

28 lines
1.3 KiB
Python

# Video bench inputs (tools/fixtures.py, for tools/bench.luau): 1 s of testsrc2 at 320x240 and 640x480, 25 fps, as
# MJPEG AVI, MPEG-1 TS, VP8 WebM (libvpx) and 8 frames of 320x240 Y4M.
# tests/gen/videobench.luau { { name, size, data } }
import importlib.util, os, tempfile
_spec = importlib.util.spec_from_file_location("_video_helpers", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_video.py"))
V = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(V)
INPUTS = ["tools/fixtures/_video.py"]
def generate(ctx):
tmp = tempfile.mkdtemp(prefix="videobench_")
out = []
for size in ("320x240", "640x480"):
src = ["-f", "lavfi", "-i", "testsrc2=size=%s:rate=25" % size, "-t", "1"]
for name, args in (("mjpeg.avi", ["-c:v", "mjpeg", "-q:v", "4"]),
("mpeg1.ts", ["-c:v", "mpeg1video", "-b:v", "2M", "-bf", "2", "-f", "mpegts"]),
("vp8.webm", ["-c:v", "libvpx", "-b:v", "1M", "-g", "50"]),
("raw.y4m", ["-pix_fmt", "yuv420p", "-frames:v", "8"])):
if name == "raw.y4m" and size == "640x480":
continue
path = os.path.join(tmp, size + "_" + name)
V.ffmpeg(src + args + [path])
out.append({"name": name, "size": size, "data": open(path, "rb").read()})
ctx.emit("videobench", out)