Processing a large video stream on an iPad

I need to take the UIImages that are served in the video stream, all this on an iPad with limited memory, quickly save them to the file system while the stream is still powered, and then process them after the recording session. I need to quickly save the UIImages so as not to interrupt the feed that will still be viewed on the iPad, I’m going to save each frame in a separate file and then read these files sequentially and merge them into a .mov file.

Tricks: how to quickly save UIImages, possibly raw data, then when processing a movie, add each UIImage file to it to create a seamless video file? I will need to process each frame, such as scaling and transform, before adding.

Any advice is appreciated.

+4
source share
1 answer

Depending on how large your images are, you can let the new β€œuse external storage” attribute do this for you. Here is an explanation that it copies from my other answer:

Since we are now on IO5, you no longer need to write images to disk. Now you can set "allow external storage" to the coredata binary attribute. According to the notes on the release of apples, this means the following:

Small data values, such as thumbnails of images, can be effectively stored in databases, but large photographs or other materials are best handled directly by the file system. Now you can specify that the value of the managed attribute of the object can be saved as an external record - see setAllowsExternalBinaryDataStorage: when enabled, the Basic data heuristically decides on the basis of value if it should save the data directly in the database or store the URI in a separate file that it manages for you. You cannot query data based on the contents of the binary if you use this option.

There are several advantages to using this approach. The first copy saves the files at least as fast as you could when writing to the file system. But if there are small images that apply to the conditions described above, it will be much faster, because they will be saved directly in the sqlite coredata file.

In addition to iOS 5, it’s very easy to work with individual managed contexts and make changes to the child context in the background. If you have completed successfully, you can combine this child context into your main managed object context and perform the necessary processing.

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

There is an NSPrivateQueueConcurrentType file for creating a "child-moc" - see [documentation for the box] [1]

And at least you can work with coredata objects that allow you to cache, limit, and optimize further processing after the download is complete.

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

0
source

All Articles