Class: Vizcore::Renderer::RenderSequence

Inherits:
Object
  • Object
show all
Defined in:
lib/vizcore/renderer/render_sequence.rb

Overview

Writes a deterministic PNG image sequence from a scene.

Constant Summary collapse

DEFAULT_FRAME_COUNT =
60
DEFAULT_FRAME_RATE =
30.0

Instance Method Summary collapse

Constructor Details

#initialize(config:, frames: DEFAULT_FRAME_COUNT, fps: DEFAULT_FRAME_RATE, width: SnapshotRenderer::DEFAULT_WIDTH, height: SnapshotRenderer::DEFAULT_HEIGHT, command_runner: Open3, ffmpeg_checker: nil) ⇒ RenderSequence

Returns a new instance of RenderSequence.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vizcore/renderer/render_sequence.rb', line 17

def initialize(
  config:,
  frames: DEFAULT_FRAME_COUNT,
  fps: DEFAULT_FRAME_RATE,
  width: SnapshotRenderer::DEFAULT_WIDTH,
  height: SnapshotRenderer::DEFAULT_HEIGHT,
  command_runner: Open3,
  ffmpeg_checker: nil
)
  @config = config
  @frames = normalize_frame_count(frames)
  @fps = normalize_frame_rate(fps)
  @width = width
  @height = height
  @command_runner = command_runner
  @ffmpeg_checker = ffmpeg_checker || method(:ffmpeg_available?)
end

Instance Method Details

#write(out:) ⇒ Hash

Returns render metadata.

Parameters:

  • out (String, Pathname)

    output directory for PNG frames, or ‘.mp4`

Returns:

  • (Hash)

    render metadata



37
38
39
40
41
42
# File 'lib/vizcore/renderer/render_sequence.rb', line 37

def write(out:)
  output_path = Pathname.new(out.to_s).expand_path
  return write_video(output_path) if video_output?(output_path)

  write_frames(output_path)
end