add UIView overlay to UIIMagePickerController video recording - ios

i want to use UIIMagePickerController to record video as i would normally do.
but i want to add a layer (UIView) that needs to be captured within the video overlay.
lets sat i have a star spinning on my view. when i will take the video i will see the star spinning as i am recording and when finish recording the same output will be.
i know this object has a property :
#property (nonatomic, retain) UIView *cameraOverlayView
but i think it needs to manage only the buttons that would not be captured.
what is the normal\recommended approach to manage such a thing?

Generally, you can add your custom overlay view and UIImagePickerController.view as subviews to one view.
User startVideoCapture and stopVideoCapture to do your task.
Sample codes:
UIImagePickerController *picker = [[[UIImagePickerController alloc] init] autorelease];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
picker.showsCameraControls = NO;
picker.delegate = self;
self.videoPicker = picker;
[self.view addSubview:self.videoPicker.view];
Of course, if you do this, the control of flash lights should be done by yourself.

Related

UIImagePickerController trim controls not showing

I've been unable to get the trim controls to appear when capturing an iOS movie.
Here's my code:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = #[(__bridge NSString *)kUTTypeMovie, (__bridge NSString *)kUTTypeImage];
imagePicker.allowsEditing = YES;
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:nil];
Additionally, I'm capturing the reply with imagePickerController:didFinishPickingMediaWithInfo:.
From searching StackOverflow I'm aware that I need to actually trim the video myself. That doesn't seem too difficult, but while I get the image picker and can capture a video I can't get the trim controls to appear! What am I missing?
My mistake was just in using video samples that were too short. They need to be over a certain length before the trimming tools will appear.

Control trim seek bar in UIImagePickerController with Source type camera

In my application i need to allow the user to record the video without any time limit (only while recording), but after recording in the edit view, i need to control the trim seek bar up to 30 sec (meaning user can use only the 30 secs video alone from the recorded full length video).
Here is my code to present the picker controller:
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
picker.allowsEditing = YES;
picker.delegate = (id<UIImagePickerControllerDelegate,UINavigationControllerDelegate>) self;
[self presentModalViewController: picker animated: YES];
if we set the video maximum duration is 30 sec means we cant record after 30 sec it will break my functionality.
my question is, is it possible to control the trim seek bar with out the knowledge of maximum duration property
or
is it possible to alert the user based on the video current trim length status while trimming?
Please guide me to fix this issue. Thanks in advance.
Your best bet would be to implement your own trimming solution.
See:
https://github.com/andrei200287/SAVideoRangeSlider

Programmatically take X amount of pictures

I am trying to implement a feature of taking X amount of pictures programmatically after entering a UIViewController for both the iPhone and iPad. I looked into UIImagePickerController but I do not want to present the camera controls and have the user hit a button to capture only one photo. Is there a way to capture X amount of photos once entering a UIViewController and storing all the photos in the end for future reference in one go?
Edit:
-(void)viewDidAppear:(BOOL)animated
{
// Create image picker controller
picker = [[UIImagePickerController alloc] init];
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else
{
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
// Set source to the camera
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Delegate is self
picker.delegate = self;
// Allow editing of image ?
picker.allowsEditing = NO;
//picker.showsCameraControls = NO;
// Show image picker
[picker animated:YES completion:nil];
}
straight away with takePicture you can not take multiple snaps, for that you have to use some video recording and get snap out of it for particular frame or time, for you more reference you can use this apple documentation for bulk snaps AVFoundation Programming Guide
You can try something like this:
int numberOfPhotos = 3; // Number of photos you want to take.
for ( int i = 0; i < numberOhPhotos; i++ )
{
// Note that you should use some sort of a pause in between each photo.
[picker takePicture];
}

iOS trim video to fixed length

I would like to be able to select a video from the photo library and pick out 15 seconds of video from an existing clip. Is there a way to force the trim to be a fixed length?
Set the UIImagePickerController property, videoMaximumDuration to the fixed length you want. From the documentation:
The maximum duration, in seconds, for a video recording.
#property (nonatomic) NSTimeInterval videoMaximumDuration
Discussion
The default value for this property is 10 minutes (600 seconds). When a user taps the Share button to send a movie to MMS, MobileMe, YouTube, or another destination, an appropriate duration limit and an appropriate video quality are enforced.
This property is available only if the mediaTypes property’s value array includes the kUTTypeMovie media type.
Can you please see the following code. I hope it will be helpful to you
-(void)recordVideo{
imagePicker = [[UIImagePickerController alloc]init];
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [[NSArray alloc]initWithObjects:(NSString *) kUTTypeMovie, (NSString *) kUTTypeMPEG4, nil];
imagePicker.videoQuality = UIImagePickerControllerQualityTypeIFrame1280x720;
[imagePicker setVideoMaximumDuration:15.0f];
sourceType = [UIImagePickerController availableMediaTypesForSourceType:imagePicker.sourceType];
if (![sourceType containsObject:(NSString *) kUTTypeMovie]) {
NSLog(#"Can not Save Video");
}
[self presentModalViewController:imagePicker animated:YES];
}
Make sure that, you have to set allowsEditing to YES before presenting the controller.

UIImagePickerController white screen?

Good morning.
I'm having trouble with a UIImagePickerController not showing anything other than white. I have a 320x320 UIImageView, in my main header file:
IBOutlet UIImageView *_cameraView;
Along with:
#property (nonatomic, retain) UIImagePickerController *_cameraPicker;
#property (nonatomic, retain) UIImage *_noCam;
_noCam is an image which is placed in the view if the user has no camera. That works fine.
I'm trying to show (without the standard camera GUI, but that can wait for now) the camera on top of this square view. In my main class I have:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(#"viewDidAppear did appear too");
//camera view etc
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//code here to not allow picture taking, probably put up something saying you don'thave a camera on your device
NSLog(#"no cam available");
_noCam = [UIImage imageNamed:#"noCam.png"];
[_cameraView setImage:_noCam];
} else {
//take the shot
_cameraPicker = [[UIImagePickerController alloc] init];
_cameraPicker.delegate = _cameraView;
_cameraPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
NSLog(#"cam is available");
}
}
I'm guessing I have a problem with setting the delegate. _self gives me an error of type:
'from incompatible type 'ViewController *const _strong'
I'm using NSLogs to check the methods are working, it tells me the viewDidLoad and viewDidAppear method were called and that a camera was detected But then I just get the white view.
Any help would be hugely appreciated.
Thanks.
You need to display the picker somehow, you can either use the default GUI:
[self presentModalViewController:_cameraPicker animated:YES];
Or check out the cameraOverlayView of UIImagePickerController.

Resources