我已经通过带有AVCaptureMovieFileOutputObject的手机摄像头捕捉视频,
我想将新的元数据添加到文件中,
我尝试使用AVAssetExportSession它,它的工作原理!
但是它花了很多时间,我想,这个方法重新编码了文件,
我只想添加新元(位置),
我尝试使用setMetadata方法AVCaptureMovieFileOutput
但我不知道怎么做,
我试试
元:
AVMutableMetadataItem *newItem = [AVMutableMetadataItem metadataItem];
newItem.identifier = [AVMutableMetadataItem identifierForKey:AVMetadataQuickTimeMetadataKeyLocationISO6709 keySpace:AVMetadataKeySpaceCommon];
newItem.key = AVMetadataQuickTimeMetadataKeyLocationISO6709;
newItem.value = [self gpsStringForVideo:gps];
Run Code Online (Sandbox Code Playgroud)
第一:
[_movieFileOutput setMetadata:@[meta]];
[_movieFileOutput startRecordingToOutputFileURL:outPutUrL recordingDelegate:self];
Run Code Online (Sandbox Code Playgroud)
但我不能得到代表的回应.
然后:
[_movieFileOutput startRecordingToOutputFileURL:outPutUrL recordingDelegate:self];
[_movieFileOutput setMetadata:@[meta]];
Run Code Online (Sandbox Code Playgroud)
我可以正常开始录制,但输出文件不包含任何信息!
有人有什么建议吗?谢谢!
我想在Portrait中设置UIViewController,我试图添加
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate {
return [UIApplication sharedApplication].statusBarOrientation != UIDeviceOrientationPortrait;
}
Run Code Online (Sandbox Code Playgroud)
但是当我在Landscape中拍摄手机时,请输入此UIViewController,
我将首先遇到风景,然后旋转到肖像!
但我不希望它显示风景,我希望它立即显示肖像,
有没有错误的设置?
编辑
我调用了错误ViewController"vcA",它出现在"vcB"中
在vcB中viewDidAppear,我打电话给
[self presentViewController:vc animated:NO completion:nil];
然后vcA将以横向显示(如果vcB在横向),
如果添加一些延迟像:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self presentViewController:vc animated:NO completion:nil];
});
Run Code Online (Sandbox Code Playgroud)
它会显示肖像,但我不知道它为什么会发生!
回答
最后,我找到了根本原因!
当我启动应用程序时,它保持纵向模式,
发布后,vcB是第一个叫VC的VC,
手机保持在风景中,因此viewDidAppear在vcB中,它会调用旋转到风景
同时在viewDidAppear中,我也打电话 present:vcA
所以目前,视图必须旋转到横向和呈现vcA(应该在肖像!!)
然后发生了糟糕的情况!
解
只需在"vcB"中禁用第一次启动旋转,然后进入viewDidAppear,它只会调用present:vcA
非常感谢!