在 iPad 上处理大型视频源
我需要获取在视频流中馈送的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据图像的大小,您可以让新的 coredata“使用外部存储”属性为您执行此操作。
这是从我的另一个答案复制的解释:
由于我们现在使用 IO5,因此您不再需要将图像写入磁盘。
您现在可以在 coredata 二进制属性上设置“允许外部存储”。根据苹果的发行说明,这意味着以下内容:
使用这种方法有几个优点。
第一个核心日期是在写入文件系统时至少尽可能快地保存文件。但如果有任何小图像适用于上述条件,速度会快得多,因为它们将直接保存在 coredata sqlite 文件中。
此外,使用 iOS 5,可以非常轻松地处理单独的托管上下文并在后台对子上下文执行更改。如果成功完成,您可以将此子上下文合并到主托管对象上下文中并执行您需要的处理。
有一个 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:
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.
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