Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

android 读取摄像头和麦克风,使用rtmp推流

Notifications You must be signed in to change notification settings

yeerwu/AndroidFFmpeg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

169 Commits

Repository files navigation

推流 所在项目 Streaming

推流

左边是推流端,右边是播放端, 由于gif图片过大,如果加载不出来,请查看art/streaming.gif

开发工具

Android Studio 3.0

Android NDK r12

使用的开源库

支持如下功能:

  • H.264/AAC 硬编 Api 18支持.
  • H.264/AAC 软编 Api 16.
  • 更多可选项配置(正在开发中).
  • 水印(正在开发中).

视频编码配置

  • 硬编 使用MediaCodec编码.
  • 软编 使用FBO读取纹理数据,由于使用FBO读取的数据是上下颠倒的,故而使用libyuv将图像旋转了180度,openh264编码.

音频编码配置

  • 硬编 使用MediaCodec编码.
  • 软编 使用fdk-aac编码为aac数据.

使用方式:

onCreate中设置初始化

CameraSetting cameraSetting = new CameraSetting();
AudioSetting audioSetting = new AudioSetting();
StreamingSetting streamingSetting = new StreamingSetting();
streamingSetting.setRtmpUrl("rtmp://www.ossrs.net:1935/live/demo")
 .setEncoderType(EncoderType.SOFT);
GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.gl_surface_view);
mMediaStreamingManager = new MediaStreamingManager(glSurfaceView);
mMediaStreamingManager.prepare(cameraSetting, streamingSetting, audioSetting);

打开摄像头在onResume中调用

mMediaStreamingManager.resume();

释放摄像头onPause中调用

mMediaStreamingManager.pause();

开始推流

mMediaStreamingManager.startStreaming();

停止推流

mMediaStreamingManager.stopStreaming();

自定义滤镜

实现setSurfaceTextureCallback接口

mMediaStreamingManager.setSurfaceTextureCallback(this);
public int onDrawFrame(int textureId, int textureWidth, int textureHeight, float[] transformMatrix)

在onDrawFrame函数中实现滤镜处理,这里的textureId参数为GLES11Ext.GL_TEXTURE_EXTERNAL_OES类型,textureWidth为纹理的宽度,textureHeight为纹理的高度,transformMatrix为纹理的textureTransform数组,返回值如果<=0或者是textureId代表不处理滤镜,否则需要返回一个GLES20.GL_TEXTURE_2D类型的纹理id,示例中使用了MagicCamera作为滤镜处理库.

关于我

wlanjie, 联系方式:qq:153920981 微信:w153920981

About

android 读取摄像头和麦克风,使用rtmp推流

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 37.3%
  • Python 30.5%
  • C 29.6%
  • RenderScript 0.7%
  • Java 0.5%
  • Objective-C 0.4%
  • Other 1.0%

AltStyle によって変換されたページ (->オリジナル) /