/README.markdown

http://github.com/mbebenita/Broadway · Markdown · 114 lines · 70 code · 44 blank · 0 comment · 0 complexity · d54ce750b204eeb49fc0f77784b838d9 MD5 · raw file

  1. Broadway.js
  2. ===========
  3. A JavaScript H.264 decoder.
  4. View a Live Demo:
  5. http://mbebenita.github.io/Broadway/foxDemo.html
  6. http://mbebenita.github.io/Broadway/storyDemo.html
  7. http://mbebenita.github.io/Broadway/treeDemo.html
  8. 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.
  9. Use a example node app as template:
  10. https://github.com/soliton4/BroadwayStream
  11. Technical info
  12. ==============
  13. The demo is Android's H.264 decoder compiled with Emscripten to JavaScript, then further optimized with
  14. Google's JavaScript closure compiler and further optimized by hand to use WebGL.
  15. Building the demo:
  16. Install and configure Emscripten (https://github.com/kripken/emscripten)
  17. The current version of Broadway was built with emscripten 1.35.12
  18. 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)
  19. Encoding Video
  20. ==============
  21. 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:
  22. ```
  23. 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
  24. ```
  25. API
  26. ===
  27. Player.js, Decoder.js and YUVWebGLCanvas.js all have a unified module definition.
  28. You can use them as plain js files or with common.js / AMD
  29. # Player.js:
  30. ```
  31. var p = new Player({
  32. <options>
  33. });
  34. p.canvas; // the canvas - put it where you want it
  35. p.decode(<h264 data>);
  36. ```
  37. ## options:
  38. useWorker true / false
  39. decode in a worker thread
  40. workerFile <string>
  41. path to Decoder.js. Only neccessary when using worker. defaults to "Decoder.js"
  42. webgl true / "auto" / false
  43. use webgl. defaults to "auto"
  44. size { width: <num>, height: <num> }
  45. initial size of the canvas. canvas will resize after video starts streaming.
  46. ## properties:
  47. canvas
  48. domNode
  49. refers to the canvas element.
  50. ## methods:
  51. decode (<bin>)
  52. feed the decoder with h264 stream data.
  53. # Decoder.js:
  54. ```
  55. var p = new Decoder({
  56. <options>
  57. });
  58. p.onPictureDecoded; // override with a callback function
  59. p.decode(<h264 data>);
  60. ```
  61. ## options:
  62. rgb true / false
  63. if true will convert the image to rgb. sligtly slower.
  64. ## properties:
  65. onPictureDecoded callback function(<bin>, width, height)
  66. will be called for each frame.
  67. ## methods:
  68. decode (<bin>)
  69. feed the decoder with h264 stream data.
  70. # [Real World Uses of Broadway.js](https://github.com/mbebenita/Broadway/wiki/Real-World-Uses)