通过视频引发的创建的画布“可能无法导出已污染的画布".保存时出错 [英] Canvas that created from video raising "Tainted canvases may not be exported." error when saving
问题描述
我正在使用此示例从HTML5视频创建快照.视频托管在我无法控制的第三方服务器上.
I'm creating snapshot from HTML5 video, using this example. Video is hosted on 3rd party servers, that I can't control.
所以我想保存图像,但是 toDataURL
由于安全原因而失败.
So I wanted to save image, but toDataURL
failing because of security reason.
这是错误:无法在"HTMLCanvasElement"上执行"toDataURL":可能无法导出污染的画布.
我想有解决图像的方法. img.crossOrigin =匿名"
像这样.此处和
I guess there is a solution for image. img.crossOrigin = "Anonymous"
something like that. Here and here.
我尝试了 videoDomElm.crossOrigin ="Anonymous"
,但是没有运气.
I tried videoDomElm.crossOrigin = "Anonymous"
, but no luck.
视频有解决方案吗?
谢谢.
推荐答案
crossOrigin ='anonymous'
只是通过跨域安全要求的解决方案的一半.如果标题允许跨域访问内容,它将导致浏览器读取响应标题而不污染画布.
crossOrigin='anonymous'
is only half the solution to passing cross-domain security requirements. It causes the browser to read the response headers and not taint the canvas if the headers allow for cross-origin access of the content.
解决方案的另一半是将服务器配置为在其响应头中发送适当的跨域许可.如果未将服务器配置为允许跨域访问,则画布仍将被污染.
The other half of the solution is for the server to be configured to send the proper cross-origin permissions in its response headers. Without the server being configured to allow cross-origin access, the canvas will still be tainted.
满足跨域安全性的唯一方法是:
The only ways to satisfy cross-origin security are:
-
视频是否与您的网页来自同一域.
Have the video originate on the same domain as your web pages.
已将视频服务器配置为在其标头中发送适当的跨域访问.
Have the video server configured to send the appropriate cross-origin access in its headers.
没有解决方法-您必须满足安全限制.
There are no workarounds -- you must satisfy the security restrictions.
这篇关于通过视频引发的创建的画布“可能无法导出已污染的画布".保存时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!