ADCS.helpers.animations.godot.render module¶
Offline video of a visualization log.
The viewer renders every frame at a fixed simulation time and camera (never
from the wall clock), so the same job gives the same frames on the same
machine. Supersampling and motion blur are done here, in linear light: the
viewer writes each sub-frame at supersample times the output resolution,
then they are averaged (box filter) and encoded with ffmpeg.
from ADCS.helpers.animations.godot.render import CameraKey, RenderJob, render_video
job = RenderJob(duration_s=12, fps=30, supersample=2, motion_blur=4, keys=[
CameraKey(at=0, mode="orbit", frame="lvlh", dist_m=1.5, yaw_deg=-140, pitch_deg=18),
CameraKey(at=8, mode="orbit", frame="lvlh", dist_m=2.0e6, yaw_deg=-60, pitch_deg=30),
])
render_video("run.vizlog", job, "run.mp4")
Camera keys are placed in video time. Between two keys of the same mode and
frame the camera eases (smoothstep) with distance interpolated
logarithmically and yaw along the shorter way round; a key with a different
mode or frame is a cut. Simulation time runs linearly from t_start to
t_end over the video.
- class ADCS.helpers.animations.godot.render.CameraKey(at, mode='orbit', frame='lvlh', dist_m=3.0, yaw_deg=-140.0, pitch_deg=18.0, fov_deg=45.0, ease='smooth')[source]¶
Bases:
objectA camera at video time
at[s].mode="earth"orbits the Earth atdist_mfrom its centre.- Parameters:
at (float)
mode (str)
frame (str)
dist_m (float)
yaw_deg (float)
pitch_deg (float)
fov_deg (float)
ease (str)
- at: float¶
- dist_m: float = 3.0¶
- ease: str = 'smooth'¶
- fov_deg: float = 45.0¶
- frame: str = 'lvlh'¶
- mode: str = 'orbit'¶
- pitch_deg: float = 18.0¶
- yaw_deg: float = -140.0¶
- class ADCS.helpers.animations.godot.render.RenderJob(duration_s=10.0, fps=30.0, width=1920, height=1080, t_start=None, t_end=None, supersample=1, motion_blur=1, shutter=0.5, quality='high', exposure='artistic', ev=0.0, overlays=<factory>, ui=False, night_vision=False, keys=<factory>)[source]¶
Bases:
objectWhat to render.
- Parameters:
t_start (float | None) – Simulation time of the first frame [s since the log epoch]; default: the start of the log.
t_end (float | None) – Simulation time of the last frame (frames span both ends); default: the end of the log.
duration_s (float) – Video length [s].
supersample (int) – Rendered at this multiple of the output size per axis (1-4), then averaged.
motion_blur (int) – Sub-frames per frame, spread over
shutterof the frame interval (1 = none).overlays (Dict[str, bool]) – Overlay groups to show, e.g.
{"vectors": False}; others keep the log’s setting.ui (bool) – Draw the timeline and HUD into the video (needs
supersample=1and at least 960x540).night_vision (bool) – Keep the spacecraft lit while it passes through eclipse.
fps (float)
width (int)
height (int)
shutter (float)
quality (str)
exposure (str)
ev (float)
keys (List[CameraKey])
- duration_s: float = 10.0¶
- ev: float = 0.0¶
- exposure: str = 'artistic'¶
- fps: float = 30.0¶
- height: int = 1080¶
- motion_blur: int = 1¶
- property n_frames: int¶
- night_vision: bool = False¶
- overlays: Dict[str, bool]¶
- quality: str = 'high'¶
- shutter: float = 0.5¶
- supersample: int = 1¶
- t_end: float | None = None¶
- t_start: float | None = None¶
- ui: bool = False¶
- width: int = 1920¶
- class ADCS.helpers.animations.godot.render.RenderResult(video: pathlib.Path | None, frames_dir: pathlib.Path, metadata: Dict[str, Any])[source]¶
Bases:
object- Parameters:
video (Path | None)
frames_dir (Path)
metadata (Dict[str, Any])
- frames_dir: Path¶
- metadata: Dict[str, Any]¶
- video: Path | None¶
- ADCS.helpers.animations.godot.render.average_linear(images, supersample, sharp=None)[source]¶
Mean of 8-bit sRGB images in linear light, then a box filter down by
supersample; back to 8-bit sRGB.- Parameters:
sharp (tuple | None) –
(with_overlays, without_overlays)at the frame time: pixels where they differ (the overlays, labels and HUD) are taken fromwith_overlaysinstead of the mean, so they are not blurred.images (Sequence[ndarray])
supersample (int)
- Return type:
ndarray
- ADCS.helpers.animations.godot.render.camera_at(keys, u)[source]¶
Camera at video time u: eased between keys of the same mode and frame, held then cut otherwise.
- Parameters:
keys (Sequence[CameraKey])
u (float)
- Return type:
Dict[str, Any]
- ADCS.helpers.animations.godot.render.find_ffmpeg()[source]¶
ffmpeg on PATH, else the binary shipped with the
imageio-ffmpegpackage (extraviz-video).- Return type:
str | None
- ADCS.helpers.animations.godot.render.linear_to_srgb(x)[source]¶
- Parameters:
x (ndarray)
- Return type:
ndarray
- ADCS.helpers.animations.godot.render.load_job(path)[source]¶
A job from JSON: the RenderJob fields, with
keysas a list of CameraKey fields.- Parameters:
path (str | Path)
- Return type:
- ADCS.helpers.animations.godot.render.parse_key(text)[source]¶
"at=0,mode=orbit,frame=lvlh,dist=1.5,yaw=-140,pitch=18,fov=45"-> CameraKey (CLI shorthand).- Parameters:
text (str)
- Return type:
- ADCS.helpers.animations.godot.render.render_video(log_path, job, out, *, binary=None, project=None, assets=None, codec='h264', crf=16, keep_frames=False, run_id=None, timeout_s=7200.0, keep_work=False, log=<built-in function print>)[source]¶
Render a vizlog to a video.
- Parameters:
out (str | Path) – Output video (the extension follows
codec), or withcodec="none"a directory for the PNGs.binary (str | Path | None) – Viewer executable (see
find_viewer()).codec (str) –
h264(default),h265,prores(10-bit, for editing) ornone(PNG frames only).crf (int) – Quality for h264/h265 (lower is better; 16 is visually lossless).
keep_frames (bool) – Keep the final PNG frames next to the video (
<out>_frames).keep_work (bool) – Keep the viewer’s raw images and the job (for debugging); their folder is in the metadata.
log_path (str | Path)
job (RenderJob)
project (str | Path | None)
assets (str | Path | None)
run_id (str | None)
timeout_s (float)
- Returns:
Paths and the metadata also written to
<out>.json.- Raises:
RuntimeError – If the viewer fails, or ffmpeg is needed but not found.
- Return type:
- ADCS.helpers.animations.godot.render.samples(job, t_first, t_last)[source]¶
Every image to render:
{i, j, u, t, cam, layer}(frame i, image j, video time u, simulation time t).The frames span the video inclusively: frame i is at u = i * h with h = duration_s / (n_frames - 1), so the first frame shows
t_startand the lastt_end, and the camera reaches the last key. Without motion blur a frame is one image of everything (layer="all"). Withmotion_blur = m, images 0..m-1 are the scene without overlays at times centred on the frame and spread evenly overshutterx h; image m is everything and m+1 the scene alone, both at the frame time (the overlays are taken from their difference, so they stay sharp).- Parameters:
job (RenderJob)
t_first (float)
t_last (float)
- Return type:
List[Dict[str, Any]]