Giter Site home page Giter Site logo

openlinzw / screenrecorder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from myrao/screenrecorder

0.0 0.0 0.0 5.52 MB

A demo of Android screen recorder, no root but SDK version should more than Android 5.0 API 21.

C 69.79% Java 23.92% Makefile 2.56% HTML 2.05% Roff 1.69%

screenrecorder's Introduction

本Demo是在作者Yrom的项目 ScreenRecorder 的基础上额外增加了悬浮窗和通知栏等特性,详情见我的博文Android实现录屏直播(二)需求才是硬道理之产品功能调研,而后又参考了 LakeinChina 作者的 librestreaming 实现推流,目前正在逐步完善中。

Updated 7.12

年初买的阿里云的ECS服务器已经到期了,所以大家无法使用之前的IP进行测试了,请大家自行搭建服务器使用吧~

Updated 5.31

工作较忙,一直没时间接着干活,终于抽了一晚上来凑合集成了音频,大家可以试试。

Updated 4.25

目前只实现了录屏的 Video 推流,有朋友提到音频迟迟没有,还有摄像头采集也将纳入计划。

TODO LIST

  • 加入摄像头采集及推流(包含拍摄直播、录屏直播两种功能,目前 Camera 还不能用,需要完善)

  • 代码重构,改善代码的可读性,并且往 SDK 的方向推进

  • ​ 加入音频采集及推流 (原谅我直接用的 librestreaming 里面的音频采集及软解码的代码,太忙了没时间自己搞)

  • ​ 修复视频端对端延迟过长的问题(目前测试 3~6 s 左右,如果还有问题的可以 M 我)


Updated 3.12

Demo 中集成了录屏直播推流的功能,内含个人自己搭建的 Nginx + rtmp 流媒体服务器,去掉了录屏存入本地文件的部分代码,之后会重新建项目完全移植过去,并且计划拥有滤镜和OpenGL来控制帧率等功能。 需要的朋友可以自行使用,推流格式:rtmp://59.130.110.19:1935/live/yourstreamingkey

仿Bilibili悬浮窗与通知栏

效果图

录屏推流直播

推流效果图

Screen Recorder

这是个 DEMO APP 主要是实现了屏幕录制功能。

通过使用 MediaProjectionManager, VirtualDisplay, MediaCodec 以及 MediaMuxer 等API,故而这个项目仅支持Android 5.0。

原理

  • Display 可以“投影”到一个 VirtualDisplay
  • 通过 MediaProjectionManager 取得的 MediaProjection创建VirtualDisplay
  • VirtualDisplay 会将图像渲染到 Surface中,而这个Surface是由MediaCodec所创建的
mEncoder = MediaCodec.createEncoderByType(MIME_TYPE);
...
mSurface = mEncoder.createInputSurface();
...
mVirtualDisplay = mMediaProjection.createVirtualDisplay(name, mWidth, mHeight, mDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC, mSurface, null, null);
  • MediaMuxer 将从 MediaCodec 得到的图像元数据封装并输出到MP4文件中
int index = mEncoder.dequeueOutputBuffer(mBufferInfo, TIMEOUT_US);
...
ByteBuffer encodedData = mEncoder.getOutputBuffer(index);
...
mMuxer.writeSampleData(mVideoTrackIndex, encodedData, mBufferInfo);

所以其实在Android 4.4上可以通过DisplayManager来创建VirtualDisplay也是可以实现录屏,但因为权限限制需要ROOT。 (see DisplayManager.createVirtualDisplay())

screenrecorder's People

Contributors

myrao avatar yrom 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.