Compose Video Streams onto a Canvas per a Layout
Description
Paints each named source into its slot’s pixel rect on a black canvas, in
slot order (first = bottom). fit = "fill" covers the rect
(scale-up + center-crop, for heads); fit = "fit" contains
(scale-down + centered pad, for content). Every chain is normalized
(fps, square pixels, yuv420p), non-reference chains freeze their
last frame if shorter, and the output is cut frame-exactly to the
reference source’s length. The output carries no audio.
Usage
compose_layout(sources, output, layout, reference = names(sources)[1],
overwrite = TRUE, dry_run = FALSE)
Arguments
sources: Named character vector or list of video paths, keyed by slot name; must cover every slot inlayout$slots.output: Path for the output video file.layout: A cornball layout:list(schema, name, canvas, slots), withslotsa named list oflist(rect = c(x, y, w, h), fit = "fill"|"fit")in integer pixels (seesystem.file("schema", "cornball-layout.md", package = "compost")).reference: Slot name whose source defines the output frame rate and length (default the first source).overwrite: If TRUE (default), overwrite the output file.dry_run: If TRUE, return the FFmpeg command without executing.
Value
Invisibly returns the output path. If dry_run, returns the command string.
Examples
layout <- list(schema = 1L, name = "vertical", canvas = c(1080L, 1920L),
slots = list(
narrator = list(rect = c(0L, 0L, 1080L, 960L),
fit = "fill"),
visual = list(rect = c(0L, 960L, 1080L, 960L),
fit = "fit")))
compose_layout(c(narrator = "head.mp4", visual = "slides.mp4"),
"composed.mp4", layout, reference = "visual")