成功捕获图像并且应用程序崩溃后,我尝试捕获视频。
if (iSRecordVideo) {
DLog(@"iSRecordVideo");
//ADD AUDIO INPUT
AVCaptureDevice *audioCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
NSError *error = nil;
AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioCaptureDevice error:&error];
if (audioInput)
{
[[self captureSession] addInput:audioInput];
}
//ADD MOVIE FILE OUTPUT
self.videoOutput = [[AVCaptureMovieFileOutput alloc] init];
Float64 TotalSeconds = 20; //Total seconds
int32_t preferredTimeScale = 20; //Frames per second
self.maxDuration = CMTimeMakeWithSeconds(TotalSeconds, preferredTimeScale); //<<SET MAX DURATION
self.videoOutput.maxRecordedDuration = self.maxDuration;
self.videoOutput.minFreeDiskSpaceLimit = 1024 * 1024;//<<SET MIN FREE SPACE IN BYTES FOR RECORDING TO CONTINUE ON A VOLUME
if (IS_IPHONE_X_S_MAX)
{
[self.captureSession setSessionPreset:AVCaptureSessionPresetMedium];
}
else
{
[[self captureSession] setSessionPreset:AVCaptureSessionPresetMedium];
}
if ([[self captureSession] canAddOutput:self.videoOutput])
[[self captureSession] addOutput:self.videoOutput];
//SET THE CONNECTION PROPERTIES (output properties)
[self CameraSetOutputProperties:audioCaptureDevice];
}
答案 0 :(得分:0)
文档说:
如果canSetSessionPreset(_ :)返回true,则可以仅设置 该预设。
你应该做
if([self.captureSession canSetSessionPreset: AVCaptureSessionPresetMedium]){
//set the medium preset
}
会话预设的默认值为“高”。
也许对于XS max,除高预设外,不允许任何其他值。