Projeto: slides de progresso de 05/11 e animacao do circuito
Deck curto com o teste dos motores na bateria, a troca pelo UNO com Wi-Fi, a animacao SVG do circuito, a base 35x35 e o que falta. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ce32b92335
commit
68c7dab989
32 files changed
+20422
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Renderiza circuito.html quadro a quadro em MP4.
|
||||
|
||||
python3 render_video.py # gera ../circuito_robo.mp4
|
||||
python3 render_video.py --quadros 1 7 22 # só PNGs nos instantes dados, na pasta indicada por --saida
|
||||
"""
|
||||
import argparse
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
AQUI = pathlib.Path(__file__).resolve().parent
|
||||
FPS, DURACAO = 30, 36
|
||||
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--quadros", nargs="*", type=float)
|
||||
ap.add_argument("--saida", default=str(AQUI))
|
||||
args = ap.parse_args()
|
||||
|
||||
with sync_playwright() as p:
|
||||
nav = p.chromium.launch()
|
||||
pag = nav.new_page(viewport={"width": 1920, "height": 1080})
|
||||
erros = []
|
||||
pag.on("pageerror", lambda e: erros.append(str(e)))
|
||||
pag.goto((AQUI / "circuito.html").as_uri())
|
||||
pag.wait_for_function("window.pronto === true || false", timeout=30000)
|
||||
pag.wait_for_timeout(800)
|
||||
|
||||
if args.quadros:
|
||||
for t in args.quadros:
|
||||
pag.evaluate(f"render({t})")
|
||||
pag.screenshot(path=f"{args.saida}/t{t:05.1f}.png")
|
||||
else:
|
||||
ff = subprocess.Popen(
|
||||
["ffmpeg", "-v", "error", "-y", "-f", "image2pipe", "-framerate", str(FPS), "-c:v", "mjpeg", "-i", "-",
|
||||
"-c:v", "libx264", "-crf", "20", "-preset", "medium", "-pix_fmt", "yuv420p", "-movflags", "+faststart",
|
||||
str(AQUI.parent / "circuito_robo.mp4")],
|
||||
stdin=subprocess.PIPE,
|
||||
)
|
||||
for i in range(FPS * DURACAO):
|
||||
pag.evaluate(f"render({i / FPS})")
|
||||
ff.stdin.write(pag.screenshot(type="jpeg", quality=95))
|
||||
if i % 150 == 0:
|
||||
print(f"{i}/{FPS * DURACAO}", flush=True)
|
||||
ff.stdin.close()
|
||||
ff.wait()
|
||||
nav.close()
|
||||
print("erros:", erros)
|
||||
Reference in new issue
Block a user