GithubHelp home page GithubHelp logo

sam-tsai / web-rtmp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yingdev/web-rtmp

0.0 1.0 0.0 45 KB

Play rtmp video stream on the web page...without Flash. (Javascript)

JavaScript 68.82% HTML 6.86% Shell 5.70% AppleScript 18.62%

web-rtmp's Introduction

Web-Rtmp

在网页上播放RTMP视频流,通过Websocket。

WARNING ============

这个项目很大程度上只能算可行性验证,不适合作为 library 使用。试验结论是:用 js 解码视频效率已经够低了,rtmp 协议增加了许多额外开销,如果单纯为了播放视频,并不明智。不如用纯粹的 ws 传送 h264 流。

基本原理

  • 服务端

    ./websockify.py 1999 <rtmp_server>:1935
  • 浏览器

    • 使用 node-rtmpapi 解析 RTMP 协议,完成握手和通信。 (yingDev的fork 增加了浏览器支持、修正了几个错误)

    • 提取其中的 H264 视频流

    • 喂给 Broadway 解码

    decoder.decode(frame);

使用

//比如 rtmp://helloworld.com/live/abc ---> app='live', streamName='abc', rtmp_server='helloworld.com'
// ./websockify.py 1999 helloworld.com:1935
var player = new WebRtmpPlayer('ws://127.0.0.1:1999', '<app>', '<streamName>', 'rtmp://<rtmp_server>/<app>');
player.canvas.style['height'] = '100%';
document.getElementById("vidCont").appendChild(player.canvas);

运行

git clone https://github.com/yingDev/Web-Rtmp.git
cd Web-Rtmp
git submodule update --init --recursive
cnpm install
# set your rtmp params in test.js first, then 
webpack -w
# setup test server
./websockify/websockify.py 1999 <rtmp_server>:1935
open index.html

局限

  • Broadway:
    The decoder ...does not support weighted prediction for P-frames and CABAC entropy encoding...

参考资料

web-rtmp's People

Contributors

yingdev avatar

Watchers

Sam TSai 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.