How to record video in iphone - iphone

HI,
I need to record video using iPhone. To do that i used UIImagePickerController. I have an iPhone 3G, with me. when i run my code to check if source type available it says device not supported. My OS is 3.2.1, where i am wrong, can some one tell me what i need to change.
Also is there some other way to record video. What i need to do is to get the video stream as it is recorded.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
NSArray *sourceTypes =
[UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
if (![sourceTypes containsObject:(NSString *)kUTTypeVideo ]){
NSLog(#"device not supported");
return;
}
//picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeVideo];
picker.videoQuality = UIImagePickerControllerQualityTypeHigh;
[self presentModalViewController:picker animated:YES];
Thanks,

That is because the 3G isn't supported for video recording.

Lance is correct. The native UIImagePickerController does not work on iPhone 3G. If an app does do video recording on a 3G they are doing a hack like taking multiple photos in succession and manually encoding a video file using the individual images.

Related

Access Photo Library via Objective-C/Xcode in iOS

I'm writing an iPhone application. I'm wondering if I can get a list of files/filenames of the photos stored in the iPhone library (or those in the simulator).
Essentially, I'm asking if I can get the filenames of the photos stored on the iPhone or simulator.
I appreciate any help, thanks!
EDIT:
image = [UIImage imageNamed:#"/Users/Library/Application Support/iPhone Simulator/5.0/Media/DCIM/100APPLE/IMG_0002.jpg"];
imageView.image = image;
doesn't work, unfortunately.
You simply have to use the UIImagePickerController.
It gives something like that:
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
// Don't forget to add UIImagePickerControllerDelegate in your .h
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
This is something of a duplicate of a SO question asked already here - Get list of all photo albums and thumbnails for each album
From that answer:
Take a look at AssetsLibrary framework.
Note that if you have access to the iOS 6 Beta, you'll want to note the changes taking place for accessing those assets. Can say no more per NDA.
Using this methods, you can easily implement that.
https://www.dropbox.com/sh/trmg44a93hwq35x/AACAVGY6VKEDR0tDUOqoxd-Ba?dl=0

iphone capturing images while recording with audio queue service

I have a audio recording program, which is implemented using audio queue service. It captured the audio data by
void AudioOutputCallback(void* inUserData,
AudioQueueRef outAQ,
AudioQueueBufferRef outBuffer)
method. But I the goal is capturing images while recording the audio file. Then I integrated the UIImagePickerController in the same ViewController to start the image capturing process.
-(IBAction)captureImage:(id)sender{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
}
But the problem is when I fired the captureImage method, the sound recording process is stop .
Please explain me, whether this is a possible task or not. Is there any other ways to achieve this goal.

how to check video camera is available on iPhone

is there any way to check video camera capability available on iPhone?
Most of the camera related availability support is exposed through the UIImagePickerController. A bit tricker thing is detection of Video Camera. You can detect the presence of a video camera in a iOS device using the following method.
- (BOOL) isVideoCameraAvailable
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
[picker release];
if (![sourceTypes containsObject:(NSString *)kUTTypeMovie ]){
return NO;
}
return YES;
}
Found this code (based on UIDevice) which helped me with this issue:
https://github.com/MugunthKumar/DeviceHelper

Turn cameraFlash On before takePicture?

Can I programmatically turn on the camera flash on a new iPhone 4 device, before taking a picture with -takePicture?
I'm developing a photo taking app for iOS 4 and want to power on the flash light before the user takes a picture, so they can see the effect of the flash in advance.
The problem seems to be that for the flash light to stay on, you'll need to set the torchMode on and this is only possible in 'video mode' (UIImagePickerControllerCameraCaptureModeVideo), while you can only ask the UIImagePickerController to takePicture when it is on 'photo mode' (UIImagePickerControllerCameraCaptureModePhoto).
So, the following works, but only shows the flash light when taking a picture:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.mediaTypes = [NSArray arrayWithObjects:#"public.image", nil];
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
[self presentModalViewController:picker animated:YES];
And this also works (shows the torch the whole time), but then I cannot take a picture.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie, nil];
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
[self presentModalViewController:picker animated:YES];
When I try the toggleTorch code found here: Turn on torch/flash on iPhone there seems to not be any live video feed in the UIImagePickerController.
Are these UIImagePickerController and AVCaptureSession compatible with each other? or are you supposed to choose for either one or the other?
And does anybody know a workaround to get both the flash mode on (or torchMode) and to be able to takePicture?
Have a look at the WWDC 2010 sessions (specifically 409) where they go into functionality like the one you're looking for.
Essentially you need to move away from UIImagePickerController if you're looking to perform these custom camera functions and move towards AVFoundation classes.

UIImagePickerController with camera source: video trimming doesn't work

I am using UIImagePickerController to record a video with the sourceType set to UIImagePickerControllerSourceTypeCamera.
I have set allowsEditing to true so that the video can be edited before the picker returns. But after I edit the video using the trimming interface and press "Pick", I only get back the original recording in the delegate, not the trimmed version. What am I doing wrong? I am using iPhone OS 3.1.3. I remember this used to work in an earlier version but it seems to be failing in the latest OS. Any help is appreciated?
By the way i confirmed that if the source of the video is UIImagePickerControllerSourceTypeSavedPhotosAlbum, the trimming works in version 3.1.3. So trimming with source as the camera is failing. Interestingly with the camera-roll/photos-album as the source, a "Choose" button appears and soon after clicking it, the controller displays a message saying the "Video is being trimmed ... ". I don't get this message when using the camera source.
Here is a snippet of the code I am using to record a video using the camera source.
- (void) recordVideo {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
picker.videoQuality = UIImagePickerControllerQualityTypeHigh;
[self presentModalViewController:picker animated:YES];
[picker release];
}
My delegate implementation is as follows:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo: (NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
self.videoPath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
...
}
Thanks a lot,
kris.
Just ran into this myself ... and found this post when looking for a solution.
looks like the only way around this is to copy the file to your app's directory, then open the UIVideoEditorController ...
Anyone know if this UIImagePickerController newly-captured video not being trimmed issue is a bug in the SDK, or are we doing something wrong?