2017-03-20 2 views
0

AVCapture를 사용하여 비디오를 녹화하고 문서 디렉토리에 저장합니다.Avcapture Record의 정확한 타임 스탬프를 기록하는 방법은 무엇입니까?

지금 녹화 버튼을 클릭하면 동영상 녹화 시작 시간이 저장됩니다.

녹음 버튼 클릭과 실제 녹음 파일 사이의 지연 시간을 밀리 초 단위로 관찰하고 있습니다.

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]; 

답변

0

왜 모든 작업을위한 시간을 결정하기 위해 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 
} 

다른 사용자 확인 here.

희망이 있습니다.

건배.

관련 문제