代码拉取完成,页面将自动刷新
This project uses Android lastest MediaCodec API 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:
@Override
public void onCreate(final Bundle savedInstanceState) {
... ...
RESConfig resConfig = RESConfig.obtain();
resConfig.setFilterMode(RESConfig.FilterMode.SOFT);
resConfig.setTargetVideoSize(new Size(720, 480));
resConfig.setBitRate(1000 * 1024);
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!!");
}
}
@Override
protected void onResume() {
super.onResume();
resClient.start();//start streaming & preview
}
@Override
protected void onPause() {
super.onPause();
resClient.stop();//stop streaming & preview
}
@Override
protected void onDestroy() {
super.onDestroy();
resClient.destroy();
}
if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
resConfig.setFrontCameraDirectionMode(RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_90 | RESConfig.DirectionMode.FLAG_DIRECTION_FLIP_HORIZONTAL);
resConfig.setBackCameraDirectionMode(RESConfig.DirectionMode.FLAG_DIRECTION_ROATATION_90);
} else {
resConfig.setFrontCameraDirectionMode(RESConfig.DirectionMode.FLAG_DIRECTION_FLIP_HORIZONTAL);
}
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();
支持两种滤镜模式:使用cpu的软模式和使用gpu(opengles)的硬模式,硬模式效率通常高于软模式。
软模式下:
硬模式下:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。