Code Monkey home page Code Monkey logo

screenrecordpushstream's Introduction

ScreenRecordPushStream

这是一个基于 rtmp 协议的 Android 录屏推流demo (Demo APK 下载)

使用方法

一、 服务器搭建

玩玩可以使用这个https://github.com/illuspas/Node-Media-Server,Node 的库自己玩玩行,用于生产差点意思。

mkdir nms
cd nms
npm install node-media-server
vi app.js

修改下 app.js里面的配置,改下 rtmp的端口就行了,你也可以使用它默认的1935

const NodeMediaServer = require('node-media-server');

const config = {
  rtmp: {
    port: 1935,
    chunk_size: 60000,
    gop_cache: true,
    ping: 30,
    ping_timeout: 60
  },
  http: {
    port: 8000,
    allow_origin: '*'
  }
};

var nms = new NodeMediaServer(config)
nms.run();

运行

node app.js
二、安装 FFmpeg 和 FFPlay

安装这两个的目的呢是可以很方便的测试,利用 FFmpeg 推流,FFPlay 播放

以mac 系统为例:

  • FFmpeg
brew install ffmpeg
  • FFPlay
brew install ffmpeg --with-ffplay
三、测试

运行 node app.js 成功后运行如下命令:

  • 推流
ffmpeg -re -i https://github.com/mabeijianxi/ScreenRecordPushStream/raw/master/test_source/xxx.mp4  -c copy -f flv rtmp://localhost:1935/rtmplive/xxx.flv
  • 拉流
ffplay rtmp://localhost:1935/rtmplive/xxx.flv

依次执行完成后将弹出 FFplay 的视频播放页面,里面会有一只很可爱的狗狗哈哈。

四、安卓客户端上推流

demo 用了 https://github.com/lakeinchina/librestreaming中的RTMP的代码,运行demo以后输入相应地址,本地 IP 用 ifconfig 获取下即可。

demo_pic

点击观看视频效果

后期计划

可以发现node-media-server 中加入了些buffer,在拉流的时候明显能感觉到延迟。后期可能会移植live555到手机端上搭建服务,这样在客户端只需要一个拉流播放器就可以了,比较便捷。

screenrecordpushstream's People

Contributors

mabeijianxi 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.