Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-19-2010, 09:39 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 2
yokkotorro is on a distinguished road
Default Simultaneous AVCaptureVideoDataOutput and AVCaptureMovieFileOutput

Hi, I need to be able to have AVCaptureVideoDataOutput and AVCaptureMovieFileOutput working at the same time. The below code works, however, the video recording does not. The didFinishRecordingToOutputFileAtURL delegate is called directly after startRecordingToOutputFileURL is called. Now if i remove AVCaptureVideoDataOutput from the AVCaptureSession by simply commenting out the line:

[captureSession addOutput:captureDataOutput];

The video recording works but then the SampleBufferDelegate is not called (which i need).

How can i go about having AVCaptureVideoDataOutput and AVCaptureMovieFileOutput working simultaneously.

Code:
- (void)initCapture {
 AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo] error:NULL]; 

 captureDataOutput = [[AVCaptureVideoDataOutput alloc] init]; 
 [captureDataOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()]; 

 m_captureFileOutput = [[AVCaptureMovieFileOutput alloc] init];

 NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey; 
 NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA]; 
 NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key]; 

 [captureDataOutput setVideoSettings:videoSettings]; 

 captureSession = [[AVCaptureSession alloc] init]; 

 [captureSession addInput:captureInput];
 [captureSession addOutput:m_captureFileOutput]; 
 [captureSession addOutput:captureDataOutput]; 

 [captureSession beginConfiguration]; 
 [captureSession setSessionPreset:AVCaptureSessionPresetLow]; 
 [captureSession commitConfiguration]; 

 [self performSelector:@selector(startRecording) withObject:nil afterDelay:10.0];
 [self performSelector:@selector(stopRecording) withObject:nil afterDelay:15.0];

 [captureSession startRunning];
}


- (void) startRecording
{
    [m_captureFileOutput startRecordingToOutputFileURL:[self tempFileURL] recordingDelegate:self];

}

- (void) stopRecording
{
    if([m_captureFileOutput isRecording])
 [m_captureFileOutput stopRecording];

}


- (NSURL *) tempFileURL
{
 NSString *outputPath = [[NSString alloc] initWithFormat:@"%@%@", NSTemporaryDirectory(), @"camera.mov"];
 NSURL *outputURL = [[NSURL alloc] initFileURLWithPath:outputPath];
 NSFileManager *fileManager = [NSFileManager defaultManager];
 if ([fileManager fileExistsAtPath:outputPath]) {
  [[NSFileManager defaultManager] removeItemAtPath:outputPath error:nil];
 [outputPath release];
 return [outputURL autorelease];
}



- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didStartRecordingToOutputFileAtURL:(NSURL *)fileURL fromConnections:(NSArray *)connections
{
 NSLog(@"start record video");
}

- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error
{
 NSLog(@"end record");
}


- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection 
{ 
      // do stuff with sampleBuffer
}

Cheers
yokkotorro is offline   Reply With Quote
Old 10-19-2010, 09:55 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 2
yokkotorro is on a distinguished road
Default

I should add i am getting the error:

Code:
Error Domain=NSOSStatusErrorDomain Code=-12780 "The operation couldn’t be completed. (OSStatus error -12780.)" UserInfo=0x23fcd0 {AVErrorRecordingSuccessfullyFinishedKey=false}
from

Code:
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error
yokkotorro is offline   Reply With Quote
Old 11-11-2010, 07:33 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 282
sparkso is on a distinguished road
Default

Quote:
Originally Posted by yokkotorro View Post
I should add i am getting the error:

Code:
Error Domain=NSOSStatusErrorDomain Code=-12780 "The operation couldn’t be completed. (OSStatus error -12780.)" UserInfo=0x23fcd0 {AVErrorRecordingSuccessfullyFinishedKey=false}
from

Code:
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error
Hi, just wondering if you got this solved yet? I am facing the same problem.
__________________
SolarSpark Apps
sparkso is offline   Reply With Quote
Old 02-13-2011, 11:55 AM   #4 (permalink)
see my iOS apps! :D
 
Join Date: Sep 2008
Location: Europe
Posts: 296
LunarMoon is on a distinguished road
Default

Quote:
Originally Posted by sparkso View Post
Hi, just wondering if you got this solved yet? I am facing the same problem.
I have contacted Apple and they say simultaneous AVCaptureVideoDataOutput + AVCaptureMovieFileOutput is not supported yet. My problem is much simpler than using both, I just wanted to trigger a method every time a frame is grabbed by the camera, but apparently this would require using AVCaptureVideoDataOutput + AVCaptureMovieFileOutput at the same time... something that according to an Apple engineer, is not supported.

I have filled a feature request on this (bugreport.apple.com). I recommend you guys to do the same, as it will increases the chances of seeing this working in a future release.

Meantime, if you discover another way...
LunarMoon is offline   Reply With Quote
Old 12-05-2011, 04:14 AM   #5 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 11
shihabkb is on a distinguished road
Default

Quote:
Originally Posted by LunarMoon View Post
I have contacted Apple and they say simultaneous AVCaptureVideoDataOutput + AVCaptureMovieFileOutput is not supported yet. My problem is much simpler than using both, I just wanted to trigger a method every time a frame is grabbed by the camera, but apparently this would require using AVCaptureVideoDataOutput + AVCaptureMovieFileOutput at the same time... something that according to an Apple engineer, is not supported.

I have filled a feature request on this (bugreport.apple.com). I recommend you guys to do the same, as it will increases the chances of seeing this working in a future release.

Meantime, if you discover another way...
Have you got any solution for your issue?

Can you solve our one issue?

We are working in iOS4 application development. Our requirement is real-time audio-video recording. Before recording the video we want process the some sort of image-processing like to embed an image and text to each frame of the video frame captured from camera. From the documentation of AVFramework, we understand that there are classes available for video-audio recording and editing. AVCatureMovieFileOutput class and AVCaptureVideoDataOutput class. But it is not possible to use the two classes at the same time, either we can use AVCaptureMovieFileOutput or we can use AVCaptureVideoDataOutput.

Please see our doubts shown below.

1) Is there any delegate available in AVCaptureMovieFileOutput class for editing the video frame before recording?

2) Is there any other class available in AVFoundation framework which supports video recording with editing functionality?

3) Is it possible to combine the functonality of AVCaptureMovieFileOutput and AVCaptureVideoDataOutput classes using any of the methods available in AVFramework or Objective C?

4) Is it possible to record the video from preview layer?

5) Could you please mention the alternate methods for implementing our requirement.

Since we are not familiar with iOS application development, it will be helpful if we get some ideas for implementation.

Thank you
shihabkb is offline   Reply With Quote
Reply

Bookmarks

Tags
avcapturemoviefileoutput, avcapturevideodataoutput, ios, record, video

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 331
7 members and 324 guests
Desert Diva, dre, hain, mottdog, oceanlablight, schmallegory
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,895
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:10 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0