Am using AVCapture to recording the video and storing in documents directory.
Right now We are storing the start time of video recording on click of the recording button click.
We are observing some delay in milliseconds between the click of recording button and the actual recording file.
dispatch_async( sessionQueue, ^{
if ( ! self.movieFileOutput.isRecording ) {
// Update the orientation on the movie file output video connection before starting recording.
AVCaptureConnection *movieFileOutputConnection = [self.movieFileOutput connectionWithMediaType:AVMediaTypeVideo];
movieFileOutputConnection.videoOrientation = videoPreviewLayerVideoOrientation;
// Start recording to a temporary file.
NSString *outputFileName = [NSUUID UUID].UUIDString;
NSString *outputFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:[outputFileName stringByAppendingPathExtension:@"mov"]];
dispatch_async(dispatch_get_main_queue(), ^{
VideoInfo *info = [dbManager getVideoWithId:self.currentVideoID];
if (info == nil) {
VideoInfo *tempVid = [[VideoInfo alloc] init];
tempVid.videoId = (int)[tempVid generateVideoID];
[dbManager insertVideoDetails:tempVid];
info = tempVid;
}
[appDelegate.realm beginWriteTransaction];
info.videoDate = [NSString stringWithFormat:@"%lld",[@(floor([[NSDate date] timeIntervalSince1970] * 1000000)) longLongValue]];
[appDelegate.realm commitWriteTransaction];
});
//
[self.movieFileOutput startRecordingToOutputFileURL:[NSURL fileURLWithPath:outputFilePath] recordingDelegate:self];
// Setup socket connection
// [[SocketManager sharedManager] socketThreadStart];
[[SocketManager sharedManager] setupSocket];
}
Can anyone guide that how we can to store the exact starting recording time (With date time with Hours,Minutes,seconds,Milliseconds)of the video with accuracy in milliseconds?
Following is the code that we are storing the date of start recording just before start capturing the output.
info.videoDate = [NSString stringWithFormat:@"%lld",[@(floor([[NSDate date] timeIntervalSince1970] * 1000000)) longLongValue]];
[appDelegate.realm commitWriteTransaction];
});
[self.movieFileOutput startRecordingToOutputFileURL:[NSURL fileURLWithPath:outputFilePath] recordingDelegate:self];