Reputation: 849
I am creating an Audio Video recording application for MAC OSX
using Objective-C
using AVfoundation
class, the video starts to record at button click.
There is an delay in audio record starting time approx 1 to 2 secs.
Here is the code i used to setup devices,
deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:inputDevice error:&error];
mic = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
microphone_input = [AVCaptureDeviceInput deviceInputWithDevice:mic error:&error];
if(!deviceInput){
NSLog(@"Error Message: %@", error);
}
if ([session canAddInput:deviceInput]) {
[session addInput:deviceInput];
}
if([session canAddInput:microphone_input]){
[session addInput:microphone_input];
}
Record Video:
CMTime fragmentInterval = kCMTimeInvalid;
[aMovieFileOutput setMovieFragmentInterval:fragmentInterval];
[aMovieFileOutput startRecordingToOutputFileURL:[NSURL fileURLWithPath: [tempFileName stringByAppendingPathExtension:@"mov"]] recordingDelegate:self];
Please help me to identify the reason for delay in audio recording when start.
Upvotes: 1
Views: 639
Reputation: 313
Creates an audio file at the location specified by the url parameter in the initWithURL:settings:error:
method. If a file already exists at that location, this method overwrites it.
The preparation invoked by this method takes place automatically when you call record. Use prepareToRecord
when you want recording to start as quickly as possible upon calling record.
Upvotes: 2