AgoraVideoFrame

The external video frame.

public class AgoraVideoFrame {
  public static final int FORMAT_NONE = -1;
  public static final int FORMAT_TEXTURE_2D = 10;
  public static final int FORMAT_TEXTURE_OES = 11;
  public static final int FORMAT_I420 = 1;
  public static final int FORMAT_BGRA = 2;
  public static final int FORMAT_NV21 = 3;
  public static final int FORMAT_RGBA = 4;
  public static final int FORMAT_I422 = 16;
  public static final int BUFFER_TYPE_NONE = -1;
  public static final int BUFFER_TYPE_BUFFER = 1;
  public static final int BUFFER_TYPE_ARRAY = 2;
  public static final int BUFFER_TYPE_TEXTURE = 3;
  public AgoraVideoFrame() {
    format = 10;
    timeStamp = 0;
    stride = 0;
    height = 0;
    textureID = 0;
    syncMode = true;
    transform = null;
    eglContext10 = null;
    eglContext14 = null;
    buf = null;
    cropLeft = 0;
    cropTop = 0;
    cropRight = 0;
    cropBottom = 0;
    rotation = 0;
    alphaStitchMode = 0;
  }
  public int format;
  public long timeStamp;
  public int stride;
  public int height;
  public int textureID;
  public boolean syncMode;
  public float[] transform;
  public javax.microedition.khronos.egl.EGLContext eglContext10;
  public android.opengl.EGLContext eglContext14;

  public byte[] buf;
  public int cropLeft;
  public int cropTop;
  public int cropRight;
  public int cropBottom;
  public int rotation;
  public int alphaStitchMode;
  @Override
  public String toString() {
    return "AgoraVideoFrame{"
        + "format=" + format + ", timeStamp=" + timeStamp + ", stride=" + stride
        + ", height=" + height + ", textureID=" + textureID
        + ", buf.length=" + (buf != null ? buf.length : 0) + ", cropLeft=" + cropLeft
        + ", cropTop=" + cropTop + ", cropRight=" + cropRight + ", cropBottom=" + cropBottom
        + ", rotation=" + rotation + ", alphaStitchMode=" + alphaStitchMode + '}';
  }
}

Attributes

format
The format of the video data:
  • 10: TEXTURE_2D
  • 11: TEXTURE_OES, usually the data captured by the camera is in this format.
  • 1: I420
  • 3: NV21
  • 4: RGBA
  • 16: I422
buf
Video frame buffer.
This parameter only applies to video data in non-Texture format.
stride
Line spacing of the incoming video frame, which must be in pixels instead of bytes. For textures, it is the width of the texture.
height
Height of the incoming video frame.
textureID
Texture ID of the frame. This parameter only applies to video data in Texture format.
syncMode
Set whether to enable the synchronization mode. After enabling, the SDK waits while Texture processing. This parameter only applies to video data in Texture format.
  • true: Enable sync mode.
  • false: Disable sync mode.
transform
Additional transform of Texture frames. This parameter only applies to video data in Texture format.
eglContext11
EGLContext11. This parameter only applies to video data in Texture format.
eglContext14
EGLContext14. This parameter only applies to video data in Texture format.
alphaBuffer

The alpha channel data output by using portrait segmentation algorithm. This data matches the size of the video frame, with each pixel value ranging from [0,255], where 0 represents the background and 255 represents the foreground (portrait).

By setting this parameter, you can render the video background into various effects, such as transparent, solid color, image, video, etc.

Attention: In custom video rendering scenarios, ensure that both the video frame and alphaBuffer are of the Full Range type; other types may cause abnormal alpha data rendering.
fillAlphaData
This parameter only applies to video data in BGRA or RGBA format. Whether to extract the alpha channel data from the video frame and automatically fill it into alphaBuffer:
  • true:Extract and fill the alpha channel data.
  • false: (Default) Do not extract and fill the Alpha channel data.
Note: For video data in BGRA or RGBA format, you can set the Alpha channel data in either of the following ways:
  • Automatically by setting this parameter to true.
  • Manually through the alphaBuffer parameter.
alphaStitchMode
When the video frame contains alpha channel data, it represents the relative position of alphaBuffer and the video frame.
  • VIDEO_NO_ALPHA_STITCH0: (Default) Only video frame, that is, alphaBuffer is not stitched with the video frame.
  • VIDEO_ALPHA_STITCH_UP(1): alphaBuffer is above the video frame.
  • VIDEO_ALPHA_STITCH_BELOW(2): alphaBuffer is below the video frame.
  • VIDEO_ALPHA_STITCH_LEFT(3): alphaBuffer is to the left of the video frame.
  • VIDEO_ALPHA_STITCH_RIGHT(4): alphaBuffer is to the right of the video frame.
cropLeft
Raw data related parameter. The number of pixels trimmed from the left. The default value is 0.
This parameter only applies to video data in non-Texture format.
cropTop
Raw data related parameter. The number of pixels trimmed from the top. The default value is 0.
This parameter only applies to video data in non-Texture format.
cropRight
Raw data related parameter. The number of pixels trimmed from the right. The default value is 0.
This parameter only applies to video data in non-Texture format.
cropBottom
Raw data related parameter. The number of pixels trimmed from the bottom. The default value is 0.
This parameter only applies to video data in non-Texture format.
rotation
Raw data related parameter. The clockwise rotation of the video frame. You can set the rotation angle as 0, 90, 180, or 270. The default value is 0.
timestamp
Timestamp (ms) of the incoming video frame. An incorrect timestamp results in frame loss or unsynchronized audio and video.