Raxol.Recording.Video (Raxol v2.6.0)

View Source

Video render target: turn a Raxol screen buffer into a rasterized frame.

This is the foundation of the LiveView -> video pipeline. A Raxol.Core.Buffer is rendered to a self-contained, themed HTML document via Raxol.LiveView.TerminalBridge and then rasterized to a PNG by a pluggable Raxol.Recording.Video.Rasterizer backend. Stitching frames into MP4/WebM/GIF (FFmpeg) and driving a virtual animation clock are later phases.

Summary

Functions

Boot a TEA module headlessly, step it over time while injecting scripted key events, capture each frame, and encode the result to a video file.

Boot a TEA module (or .exs path) headlessly, capture its current frame, and render it to PNG bytes. Starts and stops a one-off headless session.

Wrap a buffer's HTML in a standalone, self-contained document.

Render a single buffer to PNG bytes via the configured rasterizer.

Render a buffer straight to a PNG file on disk.

Functions

capture_clip(module_or_path, opts \\ [])

@spec capture_clip(
  module() | Path.t(),
  keyword()
) :: {:ok, Path.t()} | {:error, term()}

Boot a TEA module headlessly, step it over time while injecting scripted key events, capture each frame, and encode the result to a video file.

Frames change only when events fire, so this needs no animation clock for event-driven apps. The output extension selects the format (.mp4/.webm/.gif).

Options

  • :fps - frames per second (default: 10)
  • :duration_ms - clip length (default: 2000)
  • :output - output path (default: "raxol_clip.gif")
  • :events - [{ms, {:key, key}}] or [{ms, {:key, key, key_opts}}]
  • :width / :height - session dimensions
  • :event_settle_ms - wait after firing events so the update lands (default: 40)
  • plus all render_frame/2 options (:theme, :rasterizer, ...)

capture_frame(module_or_path, opts \\ [])

@spec capture_frame(
  module() | Path.t(),
  keyword()
) :: {:ok, binary()} | {:error, term()}

Boot a TEA module (or .exs path) headlessly, capture its current frame, and render it to PNG bytes. Starts and stops a one-off headless session.

Options

  • :width / :height - session dimensions (forwarded to Raxol.Headless)
  • :settle_ms - wait before capture so the first frame renders (default: 50)
  • plus all render_frame/2 options (:theme, :rasterizer, ...)

capture_frame_to_file(module_or_path, path, opts \\ [])

@spec capture_frame_to_file(module() | Path.t(), Path.t(), keyword()) ::
  {:ok, Path.t()} | {:error, term()}

Like capture_frame/2, but writes the PNG to path.

frame_html(buffer, opts \\ [])

@spec frame_html(
  map(),
  keyword()
) :: String.t()

Wrap a buffer's HTML in a standalone, self-contained document.

Colors are emitted inline (use_inline_styles: true) so the frame needs no external stylesheet; the wrapper supplies font, background, and layout.

render_frame(buffer, opts \\ [])

@spec render_frame(
  map(),
  keyword()
) :: {:ok, binary()} | {:error, term()}

Render a single buffer to PNG bytes via the configured rasterizer.

Options

  • :theme - Raxol.LiveView.TerminalBridge theme (default: :default)
  • :rasterizer - backend module (default: HeadlessChrome)
  • :background - page background CSS color
  • :font_family - CSS font stack

render_frame_to_file(buffer, path, opts \\ [])

@spec render_frame_to_file(map(), Path.t(), keyword()) ::
  {:ok, Path.t()} | {:error, term()}

Render a buffer straight to a PNG file on disk.