Broadway

一个 JavaScript H.264 解码器。「A JavaScript H.264 decoder.」

  • 所有者: mbebenita/Broadway
  • 平台: Linux, Mac, Windows
  • 许可证: Other
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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

主要指标

概览
名称与所有者mbebenita/Broadway
主编程语言C
编程语言Objective-C (语言数: 11)
平台Linux, Mac, Windows
许可证Other
所有者活动
创建于2011-10-14 18:20:43
推送于2023-01-22 15:40:35
最后一次提交2022-07-25 01:17:26
发布数1
最新版本名称0.1.0 (发布于 )
第一版名称0.1.0 (发布于 )
用户参与
星数2.8k
关注者数113
派生数429
提交数212
已启用问题?
问题数208
打开的问题数79
拉请求数18
打开的拉请求数9
关闭的拉请求数12
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?