perf.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!doctype html>
  2. <link rel="stylesheet" href="/node_modules/video.js/dist/video-js/video-js.css">
  3. <style>
  4. p {
  5. background-color: #cbcbcb;
  6. border-radius: 5px;
  7. border: thin solid #333;
  8. padding: 5px;
  9. }
  10. </style>
  11. <p>This page pushes random bytes into a SourceBuffer to allow easy testing of ExternalInterface bandwidth. If ExternalInterface cannot transmit bytes to the video.js SWF at a greater rate than the video bitrate without using up too much CPU, playback will be interrupted.</p>
  12. <video
  13. class="video-js vjs-default-skin"
  14. width="960"
  15. height="400"
  16. controls>
  17. <source src="http://vjs.zencdn.net/v/oceans.mp4" type="video/mp4">
  18. <source src="http://vjs.zencdn.net/v/oceans.webm" type="video/webm">
  19. Your browser does not support HTML video.
  20. </video>
  21. <form>
  22. <legend>Test Parameters</legend>
  23. <label>
  24. Number of bytes per append:
  25. <input id="byte-count" type="number" min="1" value="1000">
  26. </label>
  27. <label>
  28. Number of appends:
  29. <input id="append-count" type="number" min="1" value="10000">
  30. </label>
  31. </form>
  32. <button disabled>Run Test</button>
  33. <table>
  34. <caption>Test Results</caption>
  35. <thead>
  36. <tr><td>Bytes</td><td>Appends</td><td>Elapsed Milliseconds</td></tr>
  37. </thead>
  38. <tbody id="results"></tbody>
  39. </table>
  40. <script src="/node_modules/video.js/dist/video-js/video.js"></script>
  41. <script src="/dist/videojs-contrib-media-sources.js"></script>
  42. <script>
  43. var player = videojs(document.querySelector('video'), {
  44. techOrder: ['flash', 'html']
  45. }, function() {
  46. var mediaSource = new videojs.MediaSource();
  47. mediaSource.addEventListener('sourceopen', function(event) {
  48. var sourceBuffer = mediaSource.addSourceBuffer('video/flv; codecs="vp6,aac"'),
  49. button = document.querySelector('button');
  50. button.disabled = false;
  51. button.addEventListener('click', function() {
  52. var byteCount = +document.querySelector('#byte-count').value,
  53. bytes = new Uint8Array(byteCount),
  54. appendCount = +document.querySelector('#append-count').value,
  55. i = appendCount,
  56. result = document.createElement('tr'),
  57. printResults = function() {
  58. result.innerHTML = '<td>' + byteCount + '</td><td>' +
  59. appendCount + '</td><td>' +
  60. (Date.now() - start) + '</td>';
  61. document.querySelector('#results').appendChild(result);
  62. sourceBuffer.removeEventListener('updateend', printResults);
  63. button.disabled = false;
  64. },
  65. start;
  66. button.disabled = true;
  67. sourceBuffer.addEventListener('updateend', printResults);
  68. start = Date.now();
  69. while (i--) {
  70. sourceBuffer.appendBuffer(bytes, player);
  71. }
  72. }, false);
  73. }, false);
  74. player.src({
  75. src: videojs.URL.createObjectURL(mediaSource),
  76. type: "video/flv"
  77. });
  78. });
  79. </script>