• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

mbebenita/Broadway: A JavaScript H.264 decoder.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

mbebenita/Broadway

开源软件地址:

https://github.com/mbebenita/Broadway

开源编程语言:

C 64.8%

开源软件介绍:

Broadway.js

A JavaScript H.264 decoder.

View a Live Demo:
http://mbebenita.github.io/Broadway/foxDemo.html
http://mbebenita.github.io/Broadway/storyDemo.html
http://mbebenita.github.io/Broadway/treeDemo.html

The video player first needs to download the entire video before it can start playing, thus appearing to be a bit slow at first, so have patience. You can start the video by clicking on each player. The top left player runs on the main thread, the remaining players run in background worker threads.

Use a example node app as template:
https://github.com/soliton4/BroadwayStream

Technical info

The demo is Android's H.264 decoder compiled with Emscripten to JavaScript, then further optimized with Google's JavaScript closure compiler and further optimized by hand to use WebGL.

Building the demo:

Install and configure Emscripten (https://github.com/kripken/emscripten)
The current version of Broadway was built with emscripten 1.35.12

The code for the demo is in the Decoder folder, to build it run the make.py python script. (Requires at least python 2.7)

Encoding Video

The decoder expects an .mp4 file and does not support weighted prediction for P-frames and CABAC entropy encoding. To create such bitstreams use ffmpeg and x264 with the following command line options:

ffmpeg -y -i sourceFile -r 30000/1001 -b:a 2M -bt 4M -vcodec libx264 -pass 1 -coder 0 -bf 0 -flags -loop -wpredp 0 -an targetFile.mp4

API

Player.js, Decoder.js and YUVWebGLCanvas.js all have a unified module definition.
You can use them as plain js files or with common.js / AMD

Player.js:

var p = new Player({
  <options>
});

p.canvas; // the canvas - put it where you want it

p.decode(<h264 data>);

options:

useWorker true / false
decode in a worker thread

workerFile
path to Decoder.js. Only neccessary when using worker. defaults to "Decoder.js"

webgl true / "auto" / false
use webgl. defaults to "auto"

size { width: , height: }
initial size of the canvas. canvas will resize after video starts streaming.

properties:

canvas
domNode

refers to the canvas element.

methods:

decode ()

feed the decoder with h264 stream data.

Decoder.js:

var p = new Decoder({
  <options>
});

p.onPictureDecoded; // override with a callback function

p.decode(<h264 data>);

options:

rgb true / false
if true will convert the image to rgb. sligtly slower.

properties:

onPictureDecoded callback function(, width, height)

will be called for each frame.

methods:

decode ()

feed the decoder with h264 stream data.

Real World Uses of Broadway.js




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap