简体   繁体   English

从画布读取视频时出现CORS错误(受污染的画布)

[英]CORS error when reading video from canvas (tainted canvas)

I'm running an HLS stream that I want to write to a canvas; 我正在运行一个我要写入画布的HLS流; and then read pixels from the canvas. 然后从画布中读取像素。

The video gets rendered to the canvas A-ok, but it gets kicked off at: 视频会被渲染到画布A-ok,但它会在以下位置启动:

myPixel = c.getImageData(200, 200, 1, 1).data;

where it fails with: 失败的地方:

[Error] SecurityError: DOM Exception 18: An attempt was made to break through the security policy of the user agent.

[Error] Unable to get image data from canvas because the canvas has been tainted by cross-origin data.

I've set the cross-domain settings on the Wowza streaming server to: 我已将Wowza流媒体服务器上的跨域设置设置为:

<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>

and crossOrigin="anonymous" on the client side video element. 客户端视频元素上的crossOrigin="anonymous"

It works and fails with different computers on the same network, all running Safari 7.0.2/Mac. 它在同一网络上的不同计算机上运行并失败,所有计算机都运行Safari 7.0.2 / Mac。

Any good ideas for debugging this? 调试这个有什么好主意吗?

If your modifications work on some computers and not on other identically configured computers, try clearing the cache on the misbehaving computers. 如果您的修改适用于某些计算机而不适用于其他配置相同的计算机,请尝试清除行为不当的计算机上的缓存。

Force a reload on the misbehaving macs like this: 强制重新加载行为不端的mac,如下所示:

Hold Shift and Cmd and press R . 按住ShiftCmd并按R

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM