小编Kem*_*mal的帖子

canvas.toDataURL()安全错误操作不安全

当我在将视频上传到服务器之前尝试获取屏幕截图并将其另存为PNG时,我遇到了以下问题

在此输入图像描述

我希望你能解决我的问题......

/*Output image show view*/
$('#file_browse').change(function(e){
    getVideo(this);
});

var capbtn = document.querySelector('#video_capture');
var video = document.querySelector('video');
var canvas = document.querySelector('canvas');
var context = canvas.getContext('2d');
var w, h, ratio;

video.addEventListener('loadedmetadata', function() {
    ratio = video.videoWidth / video.videoHeight;
    w = video.videoWidth - 100;
    h = parseInt(w / ratio, 10);
    canvas.width = w;
    canvas.height = h;           
}, false);

capbtn.addEventListener("click", function(){
    context.fillRect(0, 0, w, h);
    context.drawImage(video, 0, 0, w, h);
    var objImageData = canvas.toDataURL("data:image/png;");  
});

function getVideo(input) {
    if (input.files && input.files[0]) { …
Run Code Online (Sandbox Code Playgroud)

javascript video html5 canvas

22
推荐指数
3
解决办法
3万
查看次数

标签 统计

canvas ×1

html5 ×1

javascript ×1

video ×1