前端实现视频播放添加水印

时间:2025-05-11 07:15:19
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <style> .container { position: relative; } .base { width: 300px; height: 200px; background-color: gray; } .canvas { position: absolute; width: 300px; height: 200px; top: 0; left: 0; z-index: 999; } </style> <div class="container"> <video class="base" src="https:///example/html5/mov_bbb.mp4" autoplay muted></video> <canvas id="canvas" class="canvas"></canvas> </div> <script> function canvas() { var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); ctx.font = '30px Arial'; ctx.fillStyle = '#000000'; ctx.fillText('Hello World', 70, 70); } canvas() </script> </body> </html>