class

PNGGIF::VideoSource::Stream

Inherits Reference < Object

A live, on-demand video decoder: a running ffmpeg whose raw-RGBA frames are pulled one at a time. Constant memory, fast first paint, re-decodes from the start on #restart (for looping). Always #close it to reap the subprocess. Build via Stream.open (returns nil on failure).

Class methods

open(file : String, cap : Int32 = DEFAULT_MAX_SIZE, max_fps : Float64 = DEFAULT_FPS) : Stream | Nil

Opens a stream for file, or nil if ffmpeg/ffprobe are missing or the first frame can't be read. cap is the long-edge pixel size frames are scaled to; max_fps caps the sampled frame rate.

Source

Instance methods

close

Terminates and reaps the ffmpeg subprocess. Idempotent.

Uses SIGKILL, not SIGTERM: ffmpeg is usually blocked writing to a back-filled stdout pipe between frames and can't act on a trapped SIGTERM, which would make wait hang. SIGKILL can't be trapped.

Source
delay

Per-frame delay in ms (from the sampled fps).

Source
next_frame

The next decoded frame, or nil at end-of-stream.

Source
restart

Restarts ffmpeg from the beginning (for looping); false on failure.

Source
vehicle

A 1-frame PNGGIF::PNG (first frame + true canvas dims) used as the resampling vehicle (create_cellmap) and dimension source by the consumer; live per-frame bitmaps come from #next_frame.

Source