How can I record a video for a certain period of time from a UIView just like we are recording a portion of the phone's screen?
Asked
Active
Viewed 2,513 times
3
-
1Just video, like a screen capture, right? – CaptJak Feb 16 '16 at 02:05
-
1Possible duplicate of [Screen capture video in iOS programmatically](http://stackoverflow.com/questions/11334977/screen-capture-video-in-ios-programmatically) – CaptJak Feb 16 '16 at 02:09
-
In fact it is the same question and ironically I didn't find the link you suggested when i searched, thank you, but! the solution which has been provided in here is much better than those in that link. – Reza.Ab Feb 16 '16 at 13:50
1 Answers
2
use Glimpse
Glimpse allows you to create videos from UIViews. More documentation is here, but basically it records animations and actions as they happen by taking screen shots of a UIView in a series and then creating a quicktime video and saving it to your app’s document folder.
Here is a sample usage:
#import <Glimpse/Glimpse.h>
@implementation myViewController
- (void)viewDidAppear
{
[super viewDidAppear:animated];
// Create a new Glimpse object.
Glimpse *glimpse = [[Glimpse alloc] init];
// Start recording and tell Glimpse what to do when you are finished
[glimpse startRecordingView:self.view onCompletion:^(NSURL *fileOuputURL) {
NSLog(@"DONE WITH OUTPUT: %@", fileOuputURL.absoluteString);
}];
// Create a subview for this example
UIView *view = [[UIView alloc] initWithFrame:CGRectInset(self.view.bounds, 40.0f 40.0f)];
view.backgroundColor = [UIColor greenColor];
view.alpha = 0.0f;
[self.view addSubview:view];
// We are going to record the view fading in.
[UIView animateWithDuration:5.0 animations:^{
view.alpha = 1.0f;
} completion:^(BOOL finished) {
// Since our animation is complete, lets tell Glimpse to stop recording.
[glimpse stop];
}];
}
@end
-
Thank you for the answer, do you think i can attach an audio file to the exported video? How can i achieve that? – Reza.Ab Feb 16 '16 at 13:17
-
-
-
-
-
Sorry, this totally works. If not @mehul, perhaps you should elaborate? – Fergus Nov 11 '19 at 21:05