HTML5 Canvas - origin-clean 标志如何设置为 false?

发布于 2024-10-17 18:47:59 字数 849 浏览 2 评论 0原文

我开始使用 HTML5 Canvas 和视频,但一直遇到这个问题:我尝试演示和实验,但无法查看它们,除非将它们上传到我的网络服务器。目前这并没有造成什么大问题,因为我正在处理相对较小的文件,但我实际上正在准备一个更大的项目,这个问题很快就会变得非常不方便。我也想弄清楚我的事实。我一直在使用我自己创建的视频和演示中的视频。我处理过很久以前编码的视频,也处理过在我的代码中使用它们之前一分钟编码的视频。结果总是相同的,使用 HTML5 视频容器可以,在 Canvas 中使用视频不行,Canvas 只是不显示任何视频(除非,就像我提到的,我将它们上传到服务器)。

这是我到目前为止找到的信息:

http://html5doctor.com/video-canvas-magic/< /a>

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#security-with-canvas-elements

(以及一些信息在 w3 上,但我不允许发布两个以上的链接)

据我所知,我的画布一定被污染了,我的文件似乎不是“原始干净”的,但这就是我所能做的弄清楚。我不明白为什么。

有谁对此了解更多并可以解释其工作原理和原因吗?

I started working with HTML5 Canvas and Video and I keep having this problem: I try demos and experiments but I can't view them unless I upload them to my web server. At the moment this doesn't pose a huge problem because I'm working with comparatively small files, but I'm actually preparing a bigger project, and this problem would become quite inconvenient very quickly. And also I would just like to get my facts straight. I have been working with both, my own created videos and those from demos. I worked with videos I encoded ages ago and I worked with videos I encoded a minute before using them in my code. It's always the same result, using the HTML5 Video container works, using video inside Canvas doesn't, Canvas just doesn't display any video (unless, like I mentioned, I upload them to a server).

This is the information I found so far:

http://html5doctor.com/video-canvas-magic/

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#security-with-canvas-elements

(and a little bit of information on w3, but I'm not allowed to post more than two links)

From what I understand, my canvas must be tainted and my files don't appear to be 'origin-clean', but this is all I have been able to figure out. I don't understand why.

Does anybody know more about this and can explain how and why this works?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

み格子的夏天 2024-10-24 18:47:59

在浏览器中,从 http:// 加载的任何内容与从 file:// URI 加载的任何内容之间存在严格的分离。这实际上是相当明智的,否则您从网络加载的随机页面将能够从您的硬盘驱动器中读取文件。 还有一些附加限制适用于 file:// URI 本身,这些都是为了不让您从网上下载的文件在您的硬盘上自由运行。

话虽如此,如果您的 HTML 文件和视频都位于硬盘上的同一目录中,那么一切都应该仍然有效,因为所有这些条件都应该得到满足。

如果您仍然遇到问题,本地开发的一种有用方法是使用轻量级 Web 服务器。我个人使用 Python 的 SimpleHTTPServer 因为它已经安装在我的机器上,但还有很多其他的 - 通常是 Web 开发框架(例如 Ruby on Rails)内置了它们。

There's a strict separation within browsers between anything loaded from http:// and anything loaded from a file:// URI. This is actually pretty sensible, otherwise random pages you loaded from the web would be able read files off your harddrive. There are several additional restrictions that apply to file:// URIs themselves, again these are aimed at not letting files you've downloaded from the web having free run of your harddrive.

Having said all that, if your HTML file and the videos are all sitting in the same directory on your harddrive then everything should still work as all these conditions should be met.

If you're still having problems, one useful approach for local development is to use a lightweight web server. Personally I use Python's SimpleHTTPServer because it was already installed on my machine, but there are many others - often web development frameworks (eg. Ruby on Rails) come with them built in.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文