A GenServer behaviour for real-time media processing pipelines.
Designed for livestreaming, camera effects, and other real-time use cases where frames are processed as they arrive.
Example
defmodule MyLivestream do
use ExCubecl.MediaPipeline
def handle_frame(frame, state) do
frame
|> ExCubecl.Filter.apply(:beauty_filter, strength: 0.5)
|> ExCubecl.Video.overlay(state.logo, x: 10, y: 10)
|> ExCubecl.Transcode.write_frame(state.encoder)
{:ok, state}
end
endCallbacks
handle_frame/2— called for each incoming frame. Receives the frame and current state, must return{:ok, new_state}or{:error, reason}.
Summary
Callbacks
@callback handle_frame(ExCubecl.VideoFrame.t(), state :: term()) :: {:ok, new_state :: term()} | {:error, term()}
Functions
@spec push_frame(GenServer.server(), ExCubecl.VideoFrame.t()) :: :ok
Pushes a frame into the pipeline for processing.
@spec start_link(module(), term(), keyword()) :: GenServer.on_start()
Starts a media pipeline GenServer.
Options
:name— register the process under a name:source— media source path or reference:encoder— encoder reference fromTranscode.start/2