【发布时间】:2017-03-20 09:39:03
【问题描述】:
我正在使用 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];
【问题讨论】:
标签: ios objective-c timestamp avcapturesession avcapture