画布上的视频平移 - 如何解决性能问题(还有:HTML5、Flash 还是其他?)

发布于 2025-01-07 16:21:09 字数 2163 浏览 0 评论 0原文

长版:

我有一个非常特殊的问题。我是一名多媒体艺术家,目前与动画师一起工作 - 我们正在尝试创建一个交互式动画,我希望将其作为网站以及 App Store 和 Android Market 上的免费应用程序在线提供。 但这是我现在面临的关键问题。

实际动画的输出视频的分辨率将很高 - 可能是高清分辨率的 4 倍或更多,但这是有原因的。这个想法是让观看者一次只能观看视频的一部分 - 就像在 Google 地图或任何其他类似画布的视图(例如 MMORPG 或策略电脑游戏)中平移时一样。因此,您一次只能看到整个图像的一部分,然后您可以四处移动以查看“角落后面”的内容。

因此,动画将是一个与 Google 地图类似的画布(平移,如果有足够的时间来实现,可能还可以缩放),但使用视频而不是图像。

出现的一个大问题是性能。我认为让它运行的最佳方法是相应地缩小不同设备的视频。但即使现在只考虑台式电脑 - 高清屏幕缩小到 720p 意味着总共有大约 4 倍 720p 的分辨率,这对于普通计算机来说可能太多而无法解码(全高清通常已经出现问题) - 输出分辨率将超过 4K 标准(5120 x 2880,而 4K 为 4096x2160)。无论如何,这是不可接受的。

但我得出的结论是,解码和渲染视频中用户看不到的部分确实没有意义(为什么要为此浪费 CPU+GPU 时间)——因为我们知道只有大约 1/6 的内容。完整的画布在任何给定时间都是可见的。 这启发了我一个想法,也许我可以将输出视频分成块 - 8 到 64 个文件并排堆叠在一起,就像表格中的单元格一样,然后让时间码计时器在某个变量中播放并按需启用视频块。当用户将画布拖动到可见元素时,它会在从全局变量读取的给定时间码处自动开始播放文件。可能存在一些启发式方法来预测用户移动并过早激活不可见块,以便消除因在视频内搜索并开始播放而导致的任何延迟。然后,不再可见的块可能会在一段时间后自行停用。

因此,我的第一次尝试是尝试看看我在平台方面的选择是什么,我确实认为它归结为:

  • HTML5 与 JavaScript(大量使用 标签)
  • Adob​​e Flash(使用 Flash Builder将应用程序部署到所有不同的设备)

并且 HTML5 确实更可取。

因此,我做了一些研究,看看是否有可能在 HTML5 中一次同步多个视频。不幸的是,它远非完美,有两个可用的“黑客”可以在 Firefox 中很好地工作,但在 Webkit 中存在错误(视频经常不同步超过几帧,有时甚至长达半秒,这将是如果它是一个分割成块/片段的单个视频,则非常明显)。更不用说我什至没有在移动平台(Android / iOS)上尝试过。

这两种方法/黑客是 Rick Waldron 的同步,如下所示:

http ://weblog.bocoup.com/html5-video-synchronizing-playback-of-two-videos/

另一种也是由 Rick 开发的是 mediagroup.js (这个在 Chrome 中根本不起作用): https://github.com/rwldrn/mediagroup.js

我的测试:http://jsfiddle.net/NIXin/EQbAx/10/

(我隐藏了控制器,因为由于某种原因,它总是比其他剪辑更早播放)

因此,在解释完所有内容之后,我非常感谢你们提供的任何反馈 - 解决此问题的最佳方法是什么以及在哪个平台上。 HTML5够成熟吗?

简短版本: 如果我仍然没有弄清楚我需要什么 - 想象一下放大到 600% 的视频,这样您就看不到所有内容(有些部分超出了屏幕),并且您需要通过拖动鼠标来平移(或在移动设备上轻弹手指)以查看视频不同位置发生的情况。我怎样才能跨平台做到这一点(让视频流畅运行),同时保持视频的高质量和分辨率?

非常感谢,如果您需要更多详细信息或对此事进行任何澄清,请告诉我。

Long version:

I have a very particular issue. I'm a multimedia artist working at the moment together with an animator - we are trying to create an interactive animation that I want to make available online as a website and as free app on the App Store and the Android Market.
But here's the key problem I am faced with now.

The output video of the actual animation will be massive in resolution - probably something like 4 or more times the HD resolution, but it's for a reason. The idea is to let the viewer only watch a part of the video at one time - like when panning around in Google Maps or any other canvas-like view (eg. MMORPG or strategy computer games). So you only see a part of the whole image at one time, and then you can move around to see what's "behind the corner".

So the animation would be a Google Maps-alike canvas (panning and perhaps zooming if there's enough time to implement it) but with video instead of images.

The big problem that comes up is performance. I was thinking that the best way to make it run would be to scale down the video for different devices accordingly. But then even just considering desktop computers for now - scaling down to 720p for HD screen means there is in total of about 4 times 720p in resolution, which is probably too much for an average computer to decode (Full HD is quite often already problematic) - and the output resolution would be more than the 4K standard (5120 by 2880, whilst 4K is 4096x2160). Anyhow, that is unacceptable.

But I reached the conclusion that there is really no point in decoding and rendering the parts of the video which are invisible to the user anyway (why waste the CPU+GPU time for that) - since we know that only about 1/6th of the full canvas would be visible at any given time.
This inspired an idea that maybe I could split the output video into blocks - something between 8 to 64 files stacked together side by side like cells in a table, then have a timecode timer playing in some variable and enabling the video-blocks on demand. As the user drags the canvas to the visible element it would automatically start the playback of the file at the given timecode read from the global variable. There could be some heuristics anticipating users movement and prematurely activating the invisible blocks in order to remove any delay caused by seeking within video and starting the playback. Then blocks which are no longer visible could deactivate themselves after a certain amount of time.

So my first attempt was to try and see what are my choices platform-wise and I really see it comes down to:

  • HTML5 with JavaScript (heavily using <video> tag)
  • Adobe Flash (using Flash Builder to deploy the apps to all the different devices)

And HTML5 would really be more preferable.

So I did some research to see if it would be at all possible to even synchronize more than one video at a time in HTML5. Unfortunately it's far from perfect, there are two available "hacks" which work well with Firefox, but are buggy in Webkit (the videos often get out of sync by more than a few frames, sometimes even up to half a second, which would be quite visible if it was a single video split into blocks/segments). Not to mention the fact that I have not even tried it on mobile platforms (Android / iOS).

These two methods/hacks are Rick Waldron's sync as shown here:

http://weblog.bocoup.com/html5-video-synchronizing-playback-of-two-videos/

And the other one, also developed by Rick is the mediagroup.js (this one doesn't work in Chrome at all):
https://github.com/rwldrn/mediagroup.js

My test here: http://jsfiddle.net/NIXin/EQbAx/10/

(I've hidden the controller, cause it is always playing back earlier than the rest of the clips for some reason)

So after explaining all that I would really appreciate any feedback from you guys - what would be the best way of solving this problem and on which platform. Is HTML5 mature enough?

Short version:
If I still haven't made it clear as to what I need - think of a video zoomed in at 600% so that you can't see everything (some bits are off screen) and you need to pan around by dragging with your mouse (or flicking your finger on mobile devices) to see what's going on in different places of the video. How could I do that (have the video run smoothly) across platforms, while retaining the high quality and resolution of the video?

Thanks a lot, let me know if you need any more details or any clarification of the matter.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文