public abstract class VideoEffect
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static class |
VideoEffect.DataFormat |
static class |
VideoEffect.FilterType |
static class |
VideoEffect.Rect |
static class |
VideoEffect.TextureData |
static class |
VideoEffect.YUVData |
构造器和说明 |
---|
VideoEffect() |
限定符和类型 | 方法和说明 |
---|---|
static int |
AddBitmap(byte[] yuv,
int width,
int height,
byte[] bitmap,
int bitmapWidth,
int bitmapHeight,
int x,
int y)
在YUV上添加图片
|
boolean |
addBitmapToI420(byte[] yuv,
int width,
int height,
byte[] bitmap,
int bitmapWidth,
int bitmapHeight,
VideoEffect.Rect rect,
int x,
int y)
在YUV数据上添加bitmap格式的图片
|
void |
addDynamicWaterMark(Bitmap[] bitmapArray,
int x,
int y,
int fps,
int cameraFps,
boolean looped)
已过时。
|
void |
addDynamicWaterMark(Bitmap[] bitmapArray,
VideoEffect.Rect rect,
int x,
int y,
int fps,
int cameraFps,
boolean looped)
添加动态水印(只需要调用一次)
|
void |
addGraffiti(Bitmap bitmap,
int x,
int y)
添加涂鸦(涂鸦需要每帧都调用)
|
void |
addWaterMark(Bitmap bitmap,
int x,
int y)
已过时。
replaced by
addWaterMark(Bitmap, Rect, int, int) |
void |
addWaterMark(Bitmap bitmap,
VideoEffect.Rect rect,
int x,
int y)
添加水印(只需要调用一次)
|
abstract void |
cameraSwitchDown()
相机切换通知
|
void |
closeDynamicWaterMark(boolean close) |
VideoEffect.TextureData[] |
dealInTexture(int textureType,
int textureId,
int srcWidth,
int srcHeight,
int cameraRotation,
int displayOrientation,
int cropWidth,
int cropHeight,
boolean needI420Data,
boolean needMirrorData)
对原始纹理进行旋转、裁剪等操作后返回一个Sample 2D类型的纹理以及yuv i420的buffer(如果需要)
|
VideoEffect.TextureData |
effectDynamicWater(VideoEffect.TextureData data,
boolean next,
boolean needI420Data)
手动动态水印
|
void |
effectDynamicWater(VideoEffect.YUVData data,
boolean next)
手动动态水印
|
VideoEffect.TextureData |
effectGraffiti(VideoEffect.TextureData data,
boolean needI420Data)
手动涂鸦
|
void |
effectGraffiti(VideoEffect.YUVData data)
手动涂鸦
|
VideoEffect.TextureData |
effectWater(VideoEffect.TextureData data,
boolean needI420Data)
手动水印
|
void |
effectWater(VideoEffect.YUVData data)
手动水印
|
abstract byte[] |
filterBitmapToRGBA(Bitmap bitmap,
int width,
int height)
对bitmap图片进行滤镜
|
abstract int |
filterBitmapToTexture(Bitmap bitmap,
int width,
int height)
对bitmap图片进行滤镜
|
abstract byte[] |
filterBufferToRGBA(VideoEffect.DataFormat format,
byte[] data,
int width,
int height)
采用GPU对buffer数据进行滤镜处理(必须在具有EGLContext的线程上进行调用)
|
abstract boolean |
filterInit(Context context)
初始化滤镜模块(已有EGLContext的线程中调用,如GLSurfaceView.Renderer 的 onSurfaceCreated )
|
abstract boolean |
filterInitWithoutGLContext(Context context)
初始化滤镜模块 如果当前线程没有EGLContext,那么该接口会创建一个
后续所有的API必须保证在*同一个*具有*GL Context*的线程被调用
|
abstract int |
filterTexture(int texture,
int width,
int height)
采用GPU对Camera采集的OES Texture进行滤镜处理 (必须在具有EGLContext的线程上进行调用)
|
abstract byte[] |
filterTextureToRGBA(int texture,
int width,
int height)
采用GPU对Camera采集的OES Texture进行滤镜处理 (必须在具有EGLContext的线程上进行调用)
|
abstract void |
filterUnInit()
滤镜模式资源释放
|
static int |
glReadPixelsPBO(int x,
int y,
int width,
int height,
int format,
int type)
JNI glReadPixels 用于PBO下GPU内存映射
|
static int |
I420ToNV21(byte[] src,
int width,
int height,
byte[] dst)
I420转NV21
|
void |
init(Context context,
boolean useFilter,
boolean hasGLContext)
初始化前处理
|
abstract void |
setBeautyLevel(int level)
设置滤镜强度
|
abstract void |
setBrightness(float brightness) |
abstract void |
setContrast(float contrast) |
abstract void |
setFilterLevel(float level)
设置滤镜强度
|
abstract void |
setFilterType(VideoEffect.FilterType type)
设置滤镜类型
|
abstract void |
setHue(float hue) |
abstract void |
setSaturation(float saturation) |
abstract void |
setSharpen(float sharpen) |
static int |
TOARGB(byte[] src,
int colourSpaceType,
int width,
int height,
byte[] dst)
TOARGB
|
void |
toI420(byte[] src,
VideoEffect.DataFormat dataFormat,
int width,
int height,
byte[] out)
原始视频数据转YUV,同时会根据配置进行水印、涂鸦等操作
|
static int |
TOYUV(byte[] data,
int colourSpaceType,
int inWidth,
int inHeight,
int rotation,
byte[] yuv,
int outWidth,
int outHeight)
原始视频数据转YUV
|
VideoEffect.YUVData[] |
TOYUV420(byte[] src,
VideoEffect.DataFormat dataFormat,
int inWidth,
int inHeight,
int cameraRotation,
int displayOrientation,
int outWidth,
int outHeight,
boolean needMirrorData,
boolean autoEffect)
原始视频数据转YUV,同时会根据配置进行水印、涂鸦、旋转等操作,保证输出的是正的YUV数据
|
void |
unInit()
销毁前处理数据
|
static int |
YUVMirror(byte[] srcYuv,
int width,
int height,
byte[] dstYuv)
mirror YUV 数据
|
static int |
YUVScale(byte[] src,
int inWidth,
int inHeight,
byte[] dst,
int outWidth,
int outHeight)
YUV I420缩放
|
@Deprecated public void addWaterMark(Bitmap bitmap, int x, int y)
addWaterMark(Bitmap, Rect, int, int)
bitmap
- 水印图片x
- 水印水平坐标X,整个图像左上角为(0,0)点y
- 水印垂直坐标Y,整个图像左上角为(0,0)点public void addWaterMark(Bitmap bitmap, VideoEffect.Rect rect, int x, int y)
bitmap
- 水印图片rect
- 水印具体位置(上下左右中四个基本位置)x
- 距离 rect 的 x 坐标y
- 距离 rect 的 y 坐标@Deprecated public void addDynamicWaterMark(Bitmap[] bitmapArray, int x, int y, int fps, int cameraFps, boolean looped)
addDynamicWaterMark(Bitmap[], int, int, int, int, boolean)
bitmapArray
- 水印图片x
- 水印水平坐标X,整个图像左上角为(0,0)点y
- 水印垂直坐标Y,整个图像左上角为(0,0)点fps
- 动态水印的帧率cameraFps
- 相机采集的帧率looped
- 是否循环播放public void addDynamicWaterMark(Bitmap[] bitmapArray, VideoEffect.Rect rect, int x, int y, int fps, int cameraFps, boolean looped)
bitmapArray
- 水印图片rect
- 水印具体位置(上下左右中四个基本位置)x
- 距离 rect 的 x 坐标y
- 距离 rect 的 y 坐标fps
- 动态水印的帧率cameraFps
- 相机采集的帧率looped
- 是否循环播放public void closeDynamicWaterMark(boolean close)
public void addGraffiti(Bitmap bitmap, int x, int y)
bitmap
- 水印图片x
- 水印水平坐标X,整个图像左上角为(0,0)点y
- 水印垂直坐标Y,整个图像左上角为(0,0)点public void init(Context context, boolean useFilter, boolean hasGLContext)
context
- 应用上下文,建议使用ApplicationContextuseFilter
- 是否使用滤镜hasGLContext
- 调用线程是否具有EGLContextpublic void unInit()
public abstract boolean filterInit(Context context)
context
- 应用上下文,建议使用ApplicationContextpublic abstract boolean filterInitWithoutGLContext(Context context)
context
- 应用上下文,建议使用ApplicationContextpublic abstract void filterUnInit()
public abstract void setFilterType(VideoEffect.FilterType type)
type
- 滤镜类型public abstract void setFilterLevel(float level)
level
- (0-1)public abstract void setBeautyLevel(int level)
level
- (0-5)public abstract void setBrightness(float brightness)
public abstract void setContrast(float contrast)
public abstract void setSaturation(float saturation)
public abstract void setHue(float hue)
public abstract void setSharpen(float sharpen)
public abstract byte[] filterBufferToRGBA(VideoEffect.DataFormat format, byte[] data, int width, int height)
format
- 数据类型data
- 原始数据width
- 图像宽height
- 图像高public abstract byte[] filterTextureToRGBA(int texture, int width, int height)
texture
- OES Texturewidth
- 采集图像宽height
- 采集图像高public abstract void cameraSwitchDown()
public abstract int filterTexture(int texture, int width, int height)
texture
- OES Texturewidth
- 采集图像宽height
- 采集图像高public abstract int filterBitmapToTexture(Bitmap bitmap, int width, int height)
bitmap
- 原始图片width
- 图片宽height
- 图片高public abstract byte[] filterBitmapToRGBA(Bitmap bitmap, int width, int height)
bitmap
- 原始图片width
- 图片宽height
- 图片高public VideoEffect.TextureData[] dealInTexture(int textureType, int textureId, int srcWidth, int srcHeight, int cameraRotation, int displayOrientation, int cropWidth, int cropHeight, boolean needI420Data, boolean needMirrorData)
textureType
- 输入纹理类型 GLES11Ext.GL_TEXTURE_EXTERNAL_OES、GLES20.GL_TEXTURE_2DtextureId
- 输入纹理IDsrcWidth
- 输入宽srcHeight
- 输入高cameraRotation
- 相机拍摄调度displayOrientation
- 计算后的显示角度cropWidth
- 裁剪宽cropHeight
- 裁剪高needI420Data
- 是否需要同时返回yuv I420格式的bufferneedMirrorData
- 是否需要镜像后的数据(主要用于前置摄像头下水印、涂鸦等本地镜像显示和编码数据的区别)public VideoEffect.YUVData[] TOYUV420(byte[] src, VideoEffect.DataFormat dataFormat, int inWidth, int inHeight, int cameraRotation, int displayOrientation, int outWidth, int outHeight, boolean needMirrorData, boolean autoEffect)
src
- 原始视频数据dataFormat
- 原始视频数据的色彩空间类型inWidth
- 输入视频宽inHeight
- 输入视频高cameraRotation
- 相机拍摄调度displayOrientation
- 计算后的显示角度outWidth
- 输出视频宽outHeight
- 输出视频高needMirrorData
- 是否需要镜像后的数据(主要用于前置摄像头下水印、涂鸦等本地镜像显示和编码数据的区别)autoEffect
- 是否自动添加上水印、涂鸦等public void toI420(byte[] src, VideoEffect.DataFormat dataFormat, int width, int height, byte[] out)
src
- 原始数据dataFormat
- 原始数据格式width
- 视频宽height
- 视频高out
- 输出buffer,由外部创建public boolean addBitmapToI420(byte[] yuv, int width, int height, byte[] bitmap, int bitmapWidth, int bitmapHeight, VideoEffect.Rect rect, int x, int y)
yuv
- 原始yuv数据width
- yuv 宽height
- yuv 高bitmap
- bitmap的数据bitmapWidth
- bitmap 宽bitmapHeight
- bitmap 高rect
- 位置(上下左右中,或者没有)x
- 距离位置的X 坐标y
- 距离位置的 Y 坐标public void effectWater(VideoEffect.YUVData data)
data
- I420格式的数据public VideoEffect.TextureData effectWater(VideoEffect.TextureData data, boolean needI420Data)
data
- 纹理格式的数据needI420Data
- 是否需要I420数据public VideoEffect.TextureData effectDynamicWater(VideoEffect.TextureData data, boolean next, boolean needI420Data)
data
- 纹理格式的数据next
- 是否递增(主要用户本地显示与推流分开调用时,保证动态水印是同一张)needI420Data
- 是否需要I420数据public void effectDynamicWater(VideoEffect.YUVData data, boolean next)
data
- I420格式的数据next
- 是否递增(主要用户本地显示与推流分开调用时,保证动态水印是同一张)public VideoEffect.TextureData effectGraffiti(VideoEffect.TextureData data, boolean needI420Data)
data
- 纹理格式的数据needI420Data
- 是否需要I420数据public void effectGraffiti(VideoEffect.YUVData data)
data
- I420格式的数据public static int TOARGB(byte[] src, int colourSpaceType, int width, int height, byte[] dst)
src
- 原始数据colourSpaceType
- 原始视频的色彩空间类型width
- 原始数据宽height
- 原始数据高dst
- 目标数据public static int I420ToNV21(byte[] src, int width, int height, byte[] dst)
src
- i420 数据width
- 宽height
- 搞dst
- NV21数据public static int glReadPixelsPBO(int x, int y, int width, int height, int format, int type)
x
- image 左上角 x 坐标y
- image 左上角 y 坐标width
- image 宽height
- image 高format
- buffer 类型type
- buffer 格式public static int TOYUV(byte[] data, int colourSpaceType, int inWidth, int inHeight, int rotation, byte[] yuv, int outWidth, int outHeight)
data
- 原始视频数据colourSpaceType
- 原始视频的色彩空间类型inWidth
- 输入视频宽inHeight
- 输入视频高rotation
- 旋转角度(0、90、180、270)yuv
- 输出的yuvoutWidth
- 输出视频宽outHeight
- 输出视频高public static int AddBitmap(byte[] yuv, int width, int height, byte[] bitmap, int bitmapWidth, int bitmapHeight, int x, int y)
yuv
- 原始YUV数据width
- yuv 宽height
- yuv 高bitmap
- 图片数据bitmapWidth
- 图片宽bitmapHeight
- 图片高x
- 图片左上角y
- 图片右上角public static int YUVMirror(byte[] srcYuv, int width, int height, byte[] dstYuv)
srcYuv
- 原始YUVwidth
- yuv宽height
- yuv高dstYuv
- 输出的yuvpublic static int YUVScale(byte[] src, int inWidth, int inHeight, byte[] dst, int outWidth, int outHeight)
src
- 原始YUV数据inWidth
- 原始宽inHeight
- 原始高dst
- 输出YUV数据outWidth
- 目标宽outHeight
- 目标高