Class 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.
-
Constructor Summary
ConstructorsConstructorDescriptionVideoFrame(int[] argb, int width, int height, long timestampMillis) Creates a new immutable frame. -
Method Summary
Modifier and TypeMethodDescriptionint[]getARGB()The raw pixels of this frame in ARGB order (the Codename One native layout).intThe frame height in pixels.voidgetRGBA(byte[] dest) Copies the pixels of this frame into the supplied buffer as tightly packed RGBA bytes (R, G, B, Aper pixel, row major).longThe presentation timestamp of this frame within the source clip in milliseconds.intgetWidth()The frame width in pixels.toImage()Wraps this frame's pixels in a Codename OneImagefor display or further processing.
-
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: the pixels in ARGB order, length must equalwidth * height -
width: the frame width in pixels -
height: the frame height in pixels -
timestampMillis: 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 lengthgetWidth() * 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, Aper pixel, row major). This is convenient when feeding the frame to native APIs that expect an RGBA byte buffer.Parameters
dest: a buffer of at leastgetWidth() * getHeight() * 4bytes
-
toImage
Wraps this frame's pixels in a Codename One
Imagefor display or further processing. A new image is created on every call.Returns
an
Imagecontaining the frame pixels
-