HTML Canvas Video Draw 2

Description

HTML Canvas Video Draw 2

View in separate window

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Video Frames</title>
    <style>
      #movieclip {/* w  w  w  .j a  va  2 s  .c  o m*/
        display: none;
      }
    </style>
  </head>
  <body>
    <canvas id="canvas" width="600" height="360"></canvas>

    <video id="movieclip" width="640" height="360" autoplay>
      <source src="video.mp4" type="video/mp4"/>
      <source src="video.webm" type="video/webm"/>
      <source src="video.ogv" type="video/ogg"/>
    </video>
  
    <script>
    window.onload = function () {
      var canvas = document.getElementById('canvas'),
          context = canvas.getContext('2d'),
          video = document.getElementById('movieclip');

      (function drawFrame () {
        window.requestAnimationFrame(drawFrame, canvas);

        context.drawImage(video, 0, 0);
      }());
    };
    </script>
  </body>
</html>



PreviousNext

Related