【问题标题】:CORS error when reading video from canvas (tainted canvas)从画布(受污染的画布)读取视频时出现 CORS 错误
【发布时间】:2014-04-18 05:49:19
【问题描述】:

我正在运行要写入画布的 HLS 流;然后从画布中读取像素。

视频被渲染到画布上 A-ok,但在以下位置开始播放:

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

失败的地方:

[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.

我已将 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"/>

crossOrigin="anonymous" 在客户端视频元素上。

它在同一网络上的不同计算机上工作和失败,所有计算机都运行 Safari 7.0.2/Mac。

有什么好的调试方法吗?

【问题讨论】:

  • 控制台中的网络部分对视频的 mime 类型(响应标头)有何说明?您还看到 Access-Control* 标头吗?
  • 不 - 我似乎没有明确收到流中的 Access-Control-headers。据我所知,完整的标题是:HTTP/1.1 200 OKDate: Thu, 13 Mar 2014 12:33:12 GMTContent-Type: application/vnd.apple.mpegurlAccept-Ranges: bytesServer: FlashCom/3.5.7Cache-Control: no-cacheContent-Length: 152

标签: javascript canvas html5-video cors


【解决方案1】:

如果您的修改在某些计算机上有效,而在其他配置相同的计算机上无效,请尝试清除行为异常计算机上的缓存。

强制重新加载行为不端的 mac,如下所示:

按住ShiftCmd,然后按R

【讨论】:

    猜你喜欢
    • 2015-06-16
    • 2014-10-07
    • 2017-07-12
    • 2014-05-07
    • 2018-02-11
    相关资源
    最近更新 更多