Class: RubyLens::Clip::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/rubylens/clip/renderer.rb

Overview

Renders a showcase HTML file into an H.264 MP4: headless Chrome steps the showcase's deterministic clip frames, and each captured frame is streamed straight into ffmpeg so no frame images ever touch disk. One render covers exactly one camera loop, so the video loops seamlessly.

Constant Summary collapse

STAGE_WIDTH =
1920
STAGE_HEIGHT =
1080
DEFAULT_FPS =
30
READY_TIMEOUT_SECONDS =
120
MARKER_COMMENT =
"RubyLens clip"

Instance Method Summary collapse

Constructor Details

#initialize(chrome:, ffmpeg:, fps: DEFAULT_FPS, frame_limit: nil, progress: nil) ⇒ Renderer

Returns a new instance of Renderer.



22
23
24
25
26
27
28
# File 'lib/rubylens/clip/renderer.rb', line 22

def initialize(chrome:, ffmpeg:, fps: DEFAULT_FPS, frame_limit: nil, progress: nil)
  @chrome = chrome
  @ffmpeg = ffmpeg
  @fps = Integer(fps)
  @frame_limit = frame_limit
  @progress = progress
end

Instance Method Details

#render(showcase_html:, output:) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/rubylens/clip/renderer.rb', line 30

def render(showcase_html:, output:)
  ChromePage.open(executable: @chrome, url: file_url(showcase_html), width: STAGE_WIDTH, height: STAGE_HEIGHT) do |page|
    wait_until_ready(page)
    preset = begin_clip(page)
    frames = frame_count(preset)
    encode(page, frames, output)
  end
  output
end