SecurityError:无法在“ HTMLCanvasElement”上执行“ toBlob”:可能无法导出污染的画布

问题描述

我正在使用以下代码从视频中提取图像,但出现了一些错误

SecurityError:无法在“ HTMLCanvasElement”上执行“ toBlob”:可能无法导出污染的画布。

经过一些SO研究之后,图像CORS似乎是一个安全问题,并提出了一些将image.crossOrigin设置为“ Anonymous”的解决方案。但是它们似乎都不适用于下面的我的代码

我应该如何/在何处进行更改以解决错误?谢谢。

 video.onseeked = () => {
            const canvas = document.createElement("canvas");
            canvas.height = video.videoHeight;
            canvas.width = video.videoWidth;
            const ctx = canvas.getContext("2d");
            ctx.drawImage(video,canvas.width,canvas.height);
            canvas.toBlob(resolve,"image/jpeg",1.0); // Where the error happens
        };

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)