## Android real-time effect filter rtmp streaming library <br/> 安卓实时滤镜RTMP推流库
This project uses Android lastest [MediaCodec API](https://developer.android.com/reference/android/media/MediaCodec.html) for video/audio encoding and popular C ibrary librtmp (source code included) for rtmp streaming, in addionion, provides ability to implement real-time effect filters after camera capturing phase and before encoding phase. Some features are:
- Support Android 4.3 and higher (Android 6.0/7.0-preview tested)
- Filters support soft mode (CPU processing) and hard mode (GPU/OpenGLES rendering)
- Soft mode filter can be implemented by processing NV21 image array captured from camera
- Hard mode filter can be implemented by rendering image texture captured from camera
- Compatible with GPUImage,use GPUImageFilter without change one line
- Support pixel rotation and flip
- Support encoding paramaters like resolution, bitrate,fps etc
- Fast front/rear camera swaping without interrupt rtmp streaming
- Support draw android View into video
### Soft Filter Mode
- Color format is NV21
- Create your own filter by extending BaseSoftVideoFilter
- Filter effect can be manipulated via java, ndk or renderscript
- Adjust your filter properties between acquireSoftVideoFilter and releaseSoftVideoFilter, call releaseSoftVideoFilter as soon as operation finished (after acquireSoftVideoFilter), interval better be less than 3ms
### Hard Filter Mode
- Create your own filter by extending either BaseHardVideoFilter or OriginalHardVideoFilter
- OriginalHardVideoFilter is more simple to use, just need to proivde custmom shader to get various effects
- BaseHardVideoFilter is more powerful and flexible and need write openGLES code by yourself. You can theoretically achieve any effects you want via BaseHardVideoFilter.
- Adjust your filter properties between acquireHardVideoFilter and releaseHardVideoFilter, call releaseHardVideoFilter as soon as operation finished (after acquireHardVideoFilter), interval better be less than 3ms
### Start/stop preview and stream:
```java
@Override
public void onCreate(final Bundle savedInstanceState) {
... ...
RESConfig resConfig = RESConfig.obtain();
resConfig.setRtmpAddr("rtmp://***");
resConfig.setFilterMode(RESConfig.FilterMode.HARD);
resConfig.setTargetVideoSize(new Size(720, 480));
resConfig.setBitRate(1000 * 1024);
resConfig.setVideoFPS(30);
resConfig.setVideoGOP(1);
resConfig.setRenderingMode(RESConfig.RenderingMode.OpenGLES);//setrender mode in softmode
resConfig.setDefaultCamera(Camera.CameraInfo.CAMERA_FACING_FRONT);
if (!resClient.prepare(resConfig)) {
Log.e("Main", "prepare,failed!!");
finish();
}
}
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
resClient.startPreview(surface, width, height);
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
resClient.updatePreview(width, height);
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
resClient.stopPreview();
return false;
}
@Override
protected void onStart() {
super.onResume();
resClient.startStreaming();
}
@Override
protected void onStop() {
super.onPause();
resClient.stopStreaming();
}
@Override
protected void onDestroy() {
super.onDestroy();
resClient.destroy();
}
```
### Set recording direction:
```java
int frontDirection, backDirection;
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_FRONT, cameraInfo);
frontDirection = cameraInfo.orientation;
Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, cameraInfo);
backDirection = cameraInfo.orientation;
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
resConfig.setFrontCameraDirectionMode((frontDirection == 90 ? RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_270 : RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_90) | RESConfig.DirectionMode.FLAG_DIRECTION_FLIP_HORIZONTAL);
resConfig.setBackCameraDirectionMode((backDirection == 90 ? RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_90 : RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_270));
} else {
resConfig.setBackCameraDirectionMode((backDirection == 90 ? RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_0 : RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_180));
resConfig.setFrontCameraDirectionMode((frontDirection == 90 ? RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_180 : RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_0) | RESConfig.DirectionMode.FLAG_DIRECTION_FLIP_HORIZONTAL);
}
```
### Add filter:
```java
BlackWhiteSoftFilter bwsFilter = new BlackWhiteSoftFilter();
resClient.setSoftVideoFilter(bwsFilter);
BaseSoftVideoFilter filter = resClient.acquireSoftVideoFilter();
if (filter != null) {
if (filter instanceof BlackWhiteFilterSoft) {
BlackWhiteFilterSoft bwsFilter = (BlackWhiteFilterSoft) filter;
blackWhiteFilter.setGap((byte) 128); // 0 ~ 255
}
... ...
resClient.releaseSoftVideoFilter();
```
#### For more information, please checkout sample code in [me.lake.librestreaming.sample.softfilter](https://github.com/lakeinchina/librestreaming/tree/master/sample/src/main/java/me/lake/librestreaming/sample/softfilter) and [me.lake.librestreaming.sample.hardfilter](https://github.com/lakeinchina/librestreaming/tree/master/sample/src/main/java/me/lake/librestreaming/sample/hardfilter).
### 简介:
- 支持cpu滤镜和gpu滤镜。
- 硬编码基于Mediacodec。
- 推流基于librtmp。
### 特性:
- 支持cpu滤镜,并可以通过处理图像数组来自定义滤镜。
- 支持gpu滤镜,并可以通过opengles绘制图像纹理来自定义滤镜。
- gpu滤镜模式下兼容GPUImage,一行代码不用修改就可以直接使用GPUImage的滤镜。
- 前后摄像头快速切换,不会打断推流。
- 可以自定义帧率,最大不会超过设备支持帧率
- 可以选择图像大小,码流比特率,具体取决于设备支持。
### 关于滤镜:
支持两种滤镜模式:使用cpu的软模式和使用gpu(opengles)的硬模式,硬模式效率通常高于软模式。
软模式下:
- 你可以通过继承BaseSoftVideoFilter创建自定义滤镜。
- sample.softfilter中有一些使用Java,NDK和RenderScript来处理图像的滤镜示例。
- 在acquireSoftVideoFilter和releaseSoftVideoFilter之间可以安全的修改滤镜的属性,不要持有滤镜超过3毫秒。
- 滤镜中的颜色格式为NV21。
硬模式下:
- 你可以通过继承BaseHardVideoFilter或者OriginalHardVideoFilter来创建自定义滤镜。
- sample.hardfilter中有一些示例。
- 继承OriginalHardVideoFilter只需要通过提供Shader就可以容易的实现大部分效果。
- 继承BaseHardVideoFilter需要自己处理opengl细节,但是可以实现任何效果。
- 在acquireHardVideoFilter和releaseHardVideoFilter之间可以安全的修改滤镜的属性。不要持有滤镜超过3毫秒。
### 关于磨皮算法:
- 使用优化过的带阈值的高斯模糊算法(Selective Gaussian Blur),sigma = 0.1,稀疏的取周围24个点,正态分布取权重计算均值。
### 关于兼容GPUImageFilter:
- 使GPUImageCompatibleFilter来兼容GPUImage的滤镜,注意不能直接使用GPUImageGroupFilter,需要把单独的滤镜用GPUImageCompatibleFilter包裹,再用HardVideoGroupFilter组合起来,具体可以参考sample中的gpuimage:SketchGroup滤镜。
没有合适的资源?快使用搜索试试~ 我知道了~
Android实时效果过滤器rtmp流媒体库。使用Mediacodec HWencoding&librtmp流媒体
共147个文件
java:78个
h:13个
xml:11个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 96 浏览量
2022-07-12
22:56:21
上传
评论
收藏 507KB ZIP 举报
温馨提示
C语言 Java 该项目使用 Android 最新的MediaCodec API进行视频/音频编码和流行的 C ibrary librtmp(包括源代码)用于 rtmp 流,此外,还提供了在相机捕获阶段和编码阶段之前实现实时效果过滤器的能力。一些特点是: 支持 Android 4.3 及更高版本(Android 6.0/7.0-preview 测试) 过滤器支持软模式(CPU 处理)和硬模式(GPU/OpenGLES 渲染) 软模式滤波器可以通过处理从相机捕获的 NV21 图像阵列来实现 硬模式过滤器可以通过渲染从相机捕获的图像纹理来实现 兼容GPUImage,使用GPUImageFilter不改一行 支持像素旋转和翻转 支持分辨率、比特率、fps等编码参数 无需中断 rtmp 流的快速前后摄像头交换 支持将android View绘制成视频 更多详情、使用方法,请下载后阅读README.md文件
资源详情
资源评论
资源推荐
收起资源包目录
Android实时效果过滤器rtmp流媒体库。使用Mediacodec HWencoding&librtmp流媒体 (147个子文件)
librtmp.3 7KB
rtmp.c 139KB
amf.c 26KB
hashswf.c 15KB
parseurl.c 7KB
colorConvert.c 6KB
restreaming.c 5KB
log.c 4KB
libresrtmp.c 4KB
sample.c 628B
COPYING 26KB
.gitignore 4KB
.gitignore 7B
.gitignore 7B
seascape.glsl 5KB
skinblurgl.glsl 2KB
seascapevertex.glsl 169B
build.gradle 1KB
build.gradle 844B
build.gradle 649B
settings.gradle 73B
handshake.h 48KB
rtmp.h 11KB
dhgroups.h 9KB
dh.h 9KB
amf.h 5KB
rtmp_sys.h 5KB
bytes.h 2KB
log.h 2KB
http.h 2KB
libresrtmp.h 1KB
colorConvert.h 1020B
log.h 394B
log.h 390B
librtmp.3.html 8KB
librtmp.pc.in 281B
RESHardVideoCore.java 36KB
RESSoftVideoCore.java 23KB
GLHelper.java 20KB
RESVideoClient.java 17KB
GLESRender.java 16KB
HardStreamingActivity.java 15KB
RESClient.java 14KB
BaseStreamingActivity.java 13KB
SeaScapeFilter.java 12KB
TextHardFilter.java 11KB
RESRtmpSender.java 10KB
RESSoftAudioCore.java 9KB
MediaCodecHelper.java 8KB
SoftStreamingActivity.java 8KB
IconHardFilter.java 6KB
VideoSenderThread.java 6KB
Base3x3SamplingHardVideoFilter.java 6KB
GLESTools.java 6KB
FakeView.java 6KB
GaussianBlurHardFilter.java 6KB
TowInputFilterHard.java 5KB
WhiteningHardVideoFilter.java 5KB
RESConfig.java 5KB
ViewHardFilter.java 5KB
RESAudioClient.java 5KB
AudioSenderThread.java 4KB
CameraHelper.java 4KB
GPUImageCompatibleFilter.java 4KB
SkinBlurHardVideoFilter.java 4KB
MainActivity.java 4KB
FLvMetaData.java 4KB
OriginalHardVideoFilter.java 4KB
RESCoreParameters.java 4KB
AnimationFilterSoft.java 3KB
AspectTextureView.java 3KB
Packager.java 3KB
IconFilterSoft.java 3KB
HardVideoGroupFilter.java 3KB
SobelEdgeDetectionHardVideoFilter.java 2KB
SkinBlurFilterSoft.java 2KB
Size.java 2KB
BlurFilterSoft.java 2KB
PcmBgmAudioFilter.java 2KB
FishEyeFilterHard.java 2KB
LogTools.java 2KB
NativeRender.java 2KB
RESByteSpeedometer.java 1KB
ColorMixHardFilter.java 1KB
TimeStampHardFilter.java 1KB
RESVideoCore.java 1KB
RESFrameRateMeter.java 1KB
DifferenceBlendFilterHard.java 1KB
BaseSoftVideoFilter.java 971B
SetVolumeAudioFilter.java 903B
BaseHardVideoFilter.java 852B
CallbackDelivery.java 810B
BlackWhiteFilterSoft.java 750B
RESConnectionListener.java 749B
RESVideoChangeListener.java 736B
RESScreenShotListener.java 732B
OffScreenGLWapper.java 700B
ColorHelper.java 679B
BaseSoftAudioFilter.java 671B
RtmpClient.java 659B
共 147 条
- 1
- 2
快撑死的鱼
- 粉丝: 1w+
- 资源: 9149
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0