import asyncio, sys, json, base64 from playwright.async_api import async_playwright BASE = "http://localhost:5173/preview/production/1b822e06-b78d-4352-884d-1f8fddabf546/" async def main(): o = json.loads(sys.argv[1]); out = sys.argv[2] async with async_playwright() as p: b = await p.chromium.launch() pg = await b.new_page() errs = [] pg.on("pageerror", lambda e: errs.append("PAGEERROR " + str(e))) pg.on("console", lambda m: errs.append(m.type + ": " + m.text) if m.type in ("error",) else None) await pg.goto(BASE + "?still=0&w=100") await pg.wait_for_function("document.title==='ready'", timeout=60000) r = await pg.evaluate("""async (o) => { const m = await import('./src/video/export.ts'); const ac = new AbortController(); let last; const t0 = performance.now(); const res = await m.exportMp4(o, (p) => { last = p }, ac.signal); const buf = new Uint8Array(await res.blob.arrayBuffer()); let bin = ''; for (let i = 0; i < buf.length; i += 0x8000) bin += String.fromCharCode.apply(null, buf.subarray(i, i + 0x8000)); return { codec: res.codec, size: buf.length, ms: Math.round(performance.now() - t0), b64: btoa(bin), last }; }""", o) open(out, 'wb').write(base64.b64decode(r.pop('b64'))) print(json.dumps(r, ensure_ascii=False)) for e in errs[:20]: print(e) await b.close() asyncio.run(main())