首页 > 代码库 > canvas 在视频中的用法

canvas 在视频中的用法

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>model</title>
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <style>
        *{margin:0;}
    </style>
</head>
<body>
    <div>
        <canvas id="mycanvas" width="640" height="1039"></canvas>
    </div>

    <video class="" id="video" width="640" autoplay style=" display:none;">
        <source src="images/video.mp4" type=‘video/mp4‘>
    </video>
<script type="text/javascript" src="js/setviewport.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script>
    function playVideo() {
        var myvideo=document.getElementById("video");

        var c=document.getElementById(mycanvas);
        var ctx=c.getContext("2d");

        ctx.clearRect(0,0,640,1039);
        ctx.drawImage(myvideo,0,0,640,1039);

        stopCanvas = setInterval(function () {
            ctx.clearRect(0,0,640,1039);
            ctx.drawImage(myvideo,0,0,640,1039);
        },30)
    }
    playVideo();
</script>

</body>
</html>

 

canvas 在视频中的用法