mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-06 05:33:38 -10:00
Farm: a piece whose runs draw only stills (a game's capture) is drawn as stills and encoded on the run's GPU
Every run of a playable's capture refused: the file extension .mp4 was not recognized as an image format.
This commit is contained in:
1 parent
5ab59a30be
commit
357941a032
1 file changed
+31
@@ -354,6 +354,32 @@ def raea_proxy(src: str, dest: str, w: int, h: int, matrix: str) -> dict:
|
||||
return {"code": code, "out": out[-1000:], "s": s}
|
||||
|
||||
|
||||
def stills_run(args, frames, first, work, env, seg, man):
|
||||
"""A video run drawn as stills and encoded: the run's frames from `first` (its warm-up ones dropped) at the piece's
|
||||
rate (its manifest's, else 30)"""
|
||||
import farm_plan
|
||||
|
||||
tmp = f"/tmp/{uuid.uuid4().hex}"
|
||||
code, out, s = run(["raea", *args, "--at", ",".join(map(str, frames)), "-o", tmp, "--manifest", man], cwd=work, env=env)
|
||||
made = sorted(n for n in os.listdir(tmp) if re.fullmatch(r"frame-\d+\.png", n)) if os.path.isdir(tmp) else []
|
||||
if code or len(made) != len(frames):
|
||||
return code or 1, out + f"\n{len(made)} of {len(frames)} stills drawn", s
|
||||
kept = f"{tmp}/kept"
|
||||
os.makedirs(kept)
|
||||
n = 0
|
||||
for i, name in enumerate(made):
|
||||
if frames[i] >= first:
|
||||
os.replace(os.path.join(tmp, name), f"{kept}/frame-{n:05d}.png")
|
||||
n += 1
|
||||
try:
|
||||
fps = float(json.load(open(man)).get("fps") or 30)
|
||||
except Exception:
|
||||
fps = 30.0
|
||||
c, o, _ = farm_plan.encode(kept, seg, fps, None, run, start=0, frames=n)
|
||||
shutil.rmtree(tmp, ignore_errors=True)
|
||||
return c, out + o, s
|
||||
|
||||
|
||||
def raea_frames(id, args, frames=None, first=0, probe=False, video=False, env=None):
|
||||
vol.reload()
|
||||
work = f"{JOBS}/{id}/work"
|
||||
@@ -379,6 +405,11 @@ def raea_frames(id, args, frames=None, first=0, probe=False, video=False, env=No
|
||||
# (farm_plan.joined), so a cut's whole edit comes back, not frame 0's alone (11-29, Dutch)
|
||||
man = f"/tmp/run-{first:05d}.json"
|
||||
code, out, s = run(["raea", *args, "--at", ",".join(map(str, frames)), "-o", seg, "--manifest", man], cwd=work, env={**(env or {}), "RAEA_TIMES": "1"})
|
||||
# a piece whose --at draws only stills (a game's, 12-05: "/tmp/run-00024.mp4: The file extension .mp4 was not
|
||||
# recognized as an image format" on every run, and a playable's capture never came back): its frames as stills,
|
||||
# encoded here into the run's H.264 part, as a Blender run's are
|
||||
if code and "not recognized as an image format" in out:
|
||||
code, out, s = stills_run(args, frames, first, work, env, seg, man)
|
||||
if os.path.exists(seg):
|
||||
shutil.move(seg, f"{dest}/run-{first:05d}.mp4")
|
||||
vol.commit()
|
||||
|
||||
Reference in new issue
Block a user