Ios 如何记录Avcapture记录开始的确切时间戳?

Ios 如何记录Avcapture记录开始的确切时间戳?,ios,objective-c,timestamp,avcapturesession,avcapture,Ios,Objective C,Timestamp,Avcapturesession,Avcapture,Am使用AVCapture录制视频并存储在文档目录中 现在,我们正在存储视频录制的开始时间,只需单击录制按钮 我们观察到点击录制按钮和实际录制文件之间的延迟(毫秒) dispatch_async( sessionQueue, ^{ if ( ! self.movieFileOutput.isRecording ) { // Update the orientation on the movie file output video connection befo

Am使用AVCapture录制视频并存储在文档目录中

现在,我们正在存储视频录制的开始时间,只需单击录制按钮

我们观察到点击录制按钮和实际录制文件之间的延迟(毫秒)

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];
       }
有谁能指导我们如何以毫秒为单位准确存储视频的准确开始录制时间(以小时、分钟、秒、毫秒为日期时间)

下面是我们在开始捕获输出之前存储开始录制日期的代码

info.videoDate = [NSString stringWithFormat:@"%lld",[@(floor([[NSDate date] timeIntervalSince1970] * 1000000)) longLongValue]];
                   [appDelegate.realm commitWriteTransaction];
               });
               [self.movieFileOutput startRecordingToOutputFileURL:[NSURL fileURLWithPath:outputFilePath] recordingDelegate:self];

为什么不使用
AVCaptureFileOutputRecordingDelegate
方法来确定所有操作的时间?检查iOS具有的委托方法列表,如下所示

- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didStartRecordingToOutputFileAtURL:(NSURL *)fileURL fromConnections:(NSArray *)connections{
       //WHEN RECORDING STARTED
}

- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error{
      //WHEN RECORDING ENDED
}
检查其他人

希望能有帮助

干杯