在 iPad 上处理大型视频源

发布于 2024-12-11 08:15:18 字数 293 浏览 0 评论 0原文

我需要获取在视频流中馈送的 UIImages,所有这些都在内存有限的 iPad 上,在流仍在馈送时将它们快速保存到文件系统,然后在“录制”会话后处理它们。我需要快速保存传入的 UIImage,以避免中断仍在 iPad 上查看的提要。我正在考虑将每个帧保存到一个单独的文件中,然后依次读取这些文件并将它们组合成一个 .mov 文件。

技巧是:如何快速保存 UIImages,可能是原始数据,然后在处理电影时,将每个 UIImage 文件附加到它以制作无缝电影文件?在附加之前,我需要对每个帧进行一些处理,例如缩放和变换。

任何建议将不胜感激。

I need to take UIImages that are being fed in a video stream, all of this is on the iPad with limited memory, save them to the file system quickly while the stream is still feeding, then process them after a "recording" session. I need to save the UIImages coming in quickly to avoid interrupting the feed which will still be viewing on the iPad. I'm thinking of saving each frame to a separate file then afterward reading these files sequentially and combining them into a .mov file.

The tricks are: how to save the UIImages quickly, maybe raw data, then when processing the movie, append each UIImage file to it to make a seamless movie file? I will need to do some processing of each frame like scaling and transforms before appending.

Any advice would be greatly appreciated.

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

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

发布评论

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

评论(1

囚你心 2024-12-18 08:15:18

根据图像的大小,您可以让新的 coredata“使用外部存储”属性为您执行此操作。
这是从我的另一个答案复制的解释:

由于我们现在使用 IO5,因此您不再需要将图像写入磁盘。
您现在可以在 coredata 二进制属性上设置“允许外部存储”。根据苹果的发行说明,这意味着以下内容:

像图像缩略图这样的小数据值可以有效地存储在
数据库,但大照片或其他媒体最好直接处理
文件系统。您现在可以指定托管的值
对象属性可以存储为外部记录 - 请参阅
setAllowsExternalBinaryDataStorage:启用后,核心数据
根据每个值试探性地决定是否应该保存数据
直接在数据库中或将 URI 存储到单独的文件中
为您管理。您无法根据二进制内容进行查询
data 属性(如果您使用此选项)。

使用这种方法有几个优点。
第一个核心日期是在写入文件系统时至少尽可能快地保存文件。但如果有任何小图像适用于上述条件,速度会快得多,因为它们将直接保存在 coredata sqlite 文件中。

此外,使用 iOS 5,可以非常轻松地处理单独的托管上下文并在后台对子上下文执行更改。如果成功完成,您可以将此子上下文合并到主托管对象上下文中并执行您需要的处理。

[child performBlock:^{
[childsave:&parentError]; //do this in background on child context
}];

有一个 NSPrivateQueueConcurrentType 用于创建“child-moc” - 请参阅 [apple 文档][1]

并且至少您可以使用 coredata 对象,这使您能够在下载完成后缓存、限制和优化进一步处理

[1]:https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdConcurrency.html#//apple_ref/doc/uid/TP40003385 了解更多信息

Depending on how big your images are, you could let the new coredata "use external storage" attribute do this for you.
Here is the explanation what it does copied from another answer of mine:

Since we are on IO5 now, you no longer need to write images to disk neccessarily.
You are now able to set "allow external storage" on an coredata binary attribute. According to apples release notes it means the following:

Small data values like image thumbnails may be efficiently stored in a
database, but large photos or other media are best handled directly by
the file system. You can now specify that the value of a managed
object attribute may be stored as an external record - see
setAllowsExternalBinaryDataStorage: When enabled, Core Data
heuristically decides on a per-value basis if it should save the data
directly in the database or store a URI to a separate file which it
manages for you. You cannot query based on the contents of a binary
data property if you use this option.

There are several advantages using this approach.
First coredate is saving the files at least as fast as you could when writing to the file system. But if there are any small images which apply to the conditions described above, it'll be much faster because they will be saved directly in the coredata sqlite file.

Further with iOS 5 it is very easy possible to work on separate managed contexts and perform changes on a child context in background. If finished successfully you can merge this child context into your main managed object context and do the processing you need.

[child performBlock:^{
[childsave:&parentError]; //do this in background on child context
}];

There is a NSPrivateQueueConcurrentType for creating "child-moc" - see [apple documentation][1]

And at least you can work with coredata objects which enables you to cache, limit and optimize further processing after your download completed

[1]: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdConcurrency.html#//apple_ref/doc/uid/TP40003385 for more info

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