itai alter
itai alter

Reputation: 601

Capture specific CALayer (and subviews) to a video file (or data) in Real Time

I have a UIView (with its CALayer) which has a UIImageView as a sub-view. The UIImageView is animated (imageView.animationImages).

I would like to capture the currently played animation to a video file, or video data (later to be converted to a video file), but not capture all the elements on the screen, like buttons and other UI, but just a specific UIView (not for a promo vid, but as part of the app's functionality).

I tried implementing ScreenCaptureView , but while it does let me capture a specific UIView into a video file in realtime, it won't capture the Animated UIImageView , it shows just the first frame...

I thought about using the CALayer's renderInContext: and then somehow appending the CGImage (current frame) to a video data and then making a video file from the data (or maybe appending directly to a video file).

I'm kinda stuck on the appending part... I don't really know what to do with the render data of the current frame.

Does anyone have any hints or suggestions?

Any help will be much appreciated :)

Upvotes: 1

Views: 935

Answers (1)

itai alter
itai alter

Reputation: 601

I made the a change to ScreenCaptureView.m and now it captures the UIImageView animation:

[self.layer renderInContext:context];

changed to:

[self.layer.presentationLayer renderInContext:context];

Although the performance is actually pretty bad on a device (iPhone 4)...

Upvotes: 1

Related Questions