public final class VideoFrame

  1. Object
  2. VideoFrame

A single decoded video frame produced by a VideoReader. The pixels are exposed as a Codename One native ARGB int[] (the same layout used by Image#getRGB() and Image#createImage(int[], int, int)), and can also be copied out as a tightly packed RGBA byte array for interoperability with native pixel buffers.

Instances are immutable and safe to hand off between threads.

Constructors

public VideoFrame(int[] argb, int width, int height, long timestampMillis)Creates a new immutable frame.

Methods

public long getTimestampMillis()The presentation timestamp of this frame within the source clip in milliseconds.
public int getWidth()The frame width in pixels.
public int getHeight()The frame height in pixels.
public int[] getARGB()The raw pixels of this frame in ARGB order (the Codename One native layout).
public void getRGBA(byte[] dest)Copies the pixels of this frame into the supplied buffer as tightly packed RGBA bytes (R, G, B, A per pixel, row major).
public Image toImage()Wraps this frame’s pixels in a Codename One Image for display or further processing.

Inherited methods

Constructor details

VideoFrame

public VideoFrame(int[] argb, int width, int height, long timestampMillis)
Creates a new immutable frame. The supplied array is referenced directly (not copied) and must not be mutated by the caller after construction.

Parameters

argb int[]
the pixels in ARGB order, length must equal width * height
width int
the frame width in pixels
height int
the frame height in pixels
timestampMillis long
the presentation timestamp of this frame in milliseconds

Method details

getTimestampMillis

public long getTimestampMillis()
The presentation timestamp of this frame within the source clip in milliseconds.

getWidth

public int getWidth()
The frame width in pixels.

getHeight

public int getHeight()
The frame height in pixels.

getARGB

public int[] getARGB()
The raw pixels of this frame in ARGB order (the Codename One native layout). The returned array is the live backing array; treat it as read-only.

Returns

an int[] of length getWidth() * getHeight()

getRGBA

public void getRGBA(byte[] dest)
Copies the pixels of this frame into the supplied buffer as tightly packed RGBA bytes (R, G, B, A per pixel, row major). This is convenient when feeding the frame to native APIs that expect an RGBA byte buffer.

Parameters

dest byte[]
a buffer of at least getWidth() * getHeight() * 4 bytes

toImage

public Image toImage()
Wraps this frame’s pixels in a Codename One Image for display or further processing. A new image is created on every call.

Returns

an Image containing the frame pixels