Code Monkey home page Code Monkey logo

androidffmpeg-1's Introduction

推流 所在项目 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

androidffmpeg-1's People

Contributors

wlanjie avatar x13945 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.