FUNCTION REFERENCE

writeVideo

Write image arrays or movie frame structures to a VideoWriter.

Write image arrays or movie frame structures to a VideoWriter.

Syntax

writeVideo(w, X)

Syntax

w.writeVideo(X)

Accepts H-by-W-by-3[-by-F] RGB, H-by-W[-by-1-by-F] grayscale or indexed arrays, or a 1-by-F struct array with cdata and colormap fields. Grayscale input to RGB profiles is replicated; indexed movie input is expanded through its colormap for RGB profiles. uint8 values are preserved. single and double intensities are clamped to [0,1], multiplied by 255 and rounded; indexed uint8 is zero based and indexed floating point is one based. Other classes, nonfinite pixels, invalid indices, changing dimensions and changing palettes are rejected. Indexed Colormap can come from the first movie frame. Output and scratch are admitted against evaluation limits; work polls cancellation between frames.

Example

file=[tempname '.avi']; w=VideoWriter(file,'Uncompressed AVI'); open(w); writeVideo(w,uint8(zeros(2,3,3))); close(w); delete(file)

Differences from MATLAB: writeVideo opens implicitly on a new handle as required by this native slice; MATLAB R2026b requires an explicit open. Floating intensities are clamped here. For native AVI, a write or property-setting error finalizes completed frames and closes the writer; for ffmpeg profiles it kills/reaps the encoder and discards the temporary file; an empty writer removes its temporary file. Deleting the handle also finalizes. Collecting the last native handle finalizes; collecting an external writer or dropping its engine kills the encoder and discards unpublished output. Finalization failure preserves the previous destination and removes the temporary file; errors on explicit close are reported, while destructor errors cannot be reported. Quality uses a square-root mapping to JPEG quantizer quality (75 maps to 87); JPEG bytes can differ across builds, which use image when available and a baseline JPEG fallback otherwise.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.