VideoFrame
- Android
更新时间不可用
用于封装要推送或处理的视频帧。
public class VideoFrame implements RefCounted {
public interface Buffer extends RefCounted {
int getWidth();
int getHeight();
I420Buffer toI420();
I010Buffer toI010();
Buffer cropAndScale(
int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth, int scaleHeight);
Buffer mirror(int frameRotation);
Buffer rotate(int frameRotation);
Buffer transform(int cropX, int cropY, int cropWidth, int cropHeight, int scaleWidth,
int scaleHeight, int frameRotation);
}
public interface TextureBuffer extends Buffer {
enum Type {
OES,
RGB
}
Type getType();
int getTextureId();
Matrix getTransformMatrix();
EglBase.Context getEglBaseContext();
float[] getTransformMatrixArray();
long getFenceObject();
}
public VideoFrame(Buffer buffer, int rotation, long timestampNs);
public Buffer getBuffer();
public int getRotation();
public long getTimestampNs();
public int getRotatedWidth();
public int getRotatedHeight();
public ColorSpace getColorSpace();
}在 Android 自采集场景中,声网推荐优先使用 io.agora.base.VideoFrame 配合 pushExternalVideoFrameById(VideoFrame frame, int videoTrackId) 推送视频帧。该类型通过统一的 Buffer 抽象封装不同的视频缓冲区,适合封装 I420、NV21、NV12 以及 Texture 等数据。
注: VideoFrame 的时间戳字段为 timestampNs,单位为纳秒;若你使用 getCurrentMonotonicTimeInMs 获取 SDK 当前单调时间,需要先将毫秒转换为纳秒再传入。
如果你的现有实现已经基于 AgoraVideoFrame 封装,仍可继续使用;但对于 Android 新接入场景,推荐优先使用 VideoFrame,因为它支持 Texture 数据,也能通过统一的 Buffer 抽象承载更多格式。
属性
| 参数名 | 描述 |
|---|---|
type | |
buffer | 视频帧缓冲区。构造 VideoFrame 时需要传入实现了 注: 该参数不可为空,否则会发生异常。相关方法包括 |
TextureBuffer | Texture 类型的视频缓冲区抽象。可获取纹理类型 |
rotation | |
timestampNs | |
colorSpace |