Documentation
¶
Overview ¶
Package media is the shared media backend for image and video generation.
It owns the two provider surfaces the Content Creator relies on:
- OpenAI-compatible /images/generations and /images/edits for stills, with optional reference images passed as JSON `images:[{image_url:dataURL}]`.
- OpenAI-compatible async /videos → GET /videos/{id} → GET /videos/{id}/content for clips, with optional `input_reference:{image_url:dataURL}` seed.
Everything is HTTP JSON. There is no SDK dependency, no shell interpolation, no bearer forwarded to arbitrary download URLs, and no automatic retry of a paid POST — a failed create surfaces as an error the caller decides about. When the corresponding config block is disabled, endpoint resolution refuses and no request is issued.
Index ¶
- func Assemble(ctx context.Context, clips []string, output, size string) error
- func DownloadVideo(ctx context.Context, ep Endpoint, id, output string) error
- func ExtractLastFrame(ctx context.Context, videoPath, output, size string) error
- func GenerateImage(ctx context.Context, ep Endpoint, prompt, size string, references []string, ...) error
- func HasFFmpeg() bool
- func HasFFprobe() bool
- type Endpoint
- type ProbeInfo
- type VideoJob
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assemble ¶
Assemble concatenates clips into a single H.264/AAC MP4 at output. Each clip is normalised (scale+pad to size when set, silent AAC stereo added if missing, common fps) so a concat is guaranteed to succeed regardless of input diversity. The final file is probed and its actual duration/resolution are validated before the temp is renamed into place.
func DownloadVideo ¶
DownloadVideo streams /videos/{id}/content to output atomically. Uses the provider bearer against the provider host; other hosts (e.g. presigned CDN URLs) would be reached through downloadURL, which does not forward the bearer.
func ExtractLastFrame ¶
ExtractLastFrame writes a single-frame image at output from the final frame of videoPath. If size is non-empty ("WxH") the frame is scaled+padded onto that canvas so it matches a later shot's resolution without stretching. Argv-only, no shell interpolation.
func GenerateImage ¶
func GenerateImage(ctx context.Context, ep Endpoint, prompt, size string, references []string, output string) error
GenerateImage produces a single PNG at output. When references is empty it calls POST /images/generations; when non-empty it calls POST /images/edits with images:[{image_url:dataURL}]. All non-URL fetches are bounded and the output is written atomically. Errors are redacted of the API key.
This is a paid POST: it is issued once, exactly. No automatic retry, and no hidden fallback to a different endpoint on 4xx.
func HasFFmpeg ¶
func HasFFmpeg() bool
HasFFmpeg reports whether ffmpeg is available. Callers use it to render a clear "install ffmpeg" hint instead of failing mid-workflow.
func HasFFprobe ¶
func HasFFprobe() bool
Types ¶
type Endpoint ¶
Endpoint is a resolved provider target: base URL, credential, model, plus any extra headers the provider needs. It is what every media call takes.
func ImageEndpoint ¶
ImageEndpoint resolves the image generation endpoint from cfg.ImageGen, falling back through cfg.ImageGen.Provider → cfg.Providers[id] → openai defaults. It refuses when the block is disabled or no key is available.
type VideoJob ¶
type VideoJob struct {
ID string `json:"id"`
Status string `json:"status"`
Progress int `json:"progress"`
Error string `json:"error,omitempty"`
}
VideoJob is the trimmed view of a provider video job the workflow needs. Status mirrors the provider ("queued"|"in_progress"|"completed"|"failed"), Progress is 0..100, and Error is non-empty when the provider reports one.
func CreateVideo ¶
func CreateVideo(ctx context.Context, ep Endpoint, prompt, size string, seconds int, referencePath string) (VideoJob, error)
CreateVideo POSTs /videos with the prompt, size, seconds, and an optional image reference encoded as data URL under input_reference.image_url. It returns the queued VideoJob synchronously; the actual render happens on the provider and is polled with GetVideo. Paid call, issued once — no retry.