我使用SCRecorder自定义视频。我想导入一些本地视频来制作更长的视频并保存到相机胶卷。我使用SCRecord lib来实现它。首先,我为每个本地视频制作每个SCRecordSegment:
filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,[NSString stringWithFormat:@"%@.mp4",videoTitle]];
// Create
SCRecordSessionSegment *record = [[SCRecordSessionSegment alloc] initWithURL:[NSURL URLWithString:filePath] info:nil];
然后我创建了RecordSession:
SCRecordSession *recordSession = [SCRecordSession recordSession];
[recordSession addSegment:record];
但是当我保存到相机胶卷时崩溃了。
- (void)saveToCameraRoll : (SCRecordSession *)recordSession{
self.navigationItem.rightBarButtonItem.enabled = NO;
SCAssetExportSession *exportSession = [[SCAssetExportSession alloc] initWithAsset:recordSession.assetRepresentingSegments];
exportSession.videoConfiguration.filter = nil;
exportSession.videoConfiguration.preset = SCPresetHighestQuality;
exportSession.audioConfiguration.preset = SCPresetHighestQuality;
exportSession.videoConfiguration.maxFrameRate = 35;
exportSession.outputUrl = recordSession.outputUrl;
exportSession.outputFileType = AVFileTypeMPEG4;
exportSession.delegate = self;
exportSession.contextType = SCContextTypeAuto;
NSLog(@"Starting exporting");
CFTimeInterval time = CACurrentMediaTime();
__weak typeof(self) wSelf = self;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
__strong typeof(self) strongSelf = wSelf;
if (!exportSession.cancelled) {
NSLog(@"Completed compression in %fs", CACurrentMediaTime() - time);
}
NSError *error = exportSession.error;
if (exportSession.cancelled) {
NSLog(@"Export was cancelled");
} else if (error == nil) {
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[exportSession.outputUrl saveToCameraRollWithCompletion:^(NSString * _Nullable path, NSError * _Nullable error) {
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
if (error == nil) {
[[[UIAlertView alloc] initWithTitle:@"Saved to camera roll" message:@"" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
} else {
[[[UIAlertView alloc] initWithTitle:@"Failed to save" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}
}];
} else {
if (!exportSession.cancelled) {
[[[UIAlertView alloc] initWithTitle:@"Failed to save" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}
}
}];
}
答案 0 :(得分:0)
您没有先合并视频片段。以下是我的代码
中的示例Error using integralCalc/finalInputChecks (line 515)
Output of the function must be the same size as the input. If FUN is an array-valued integrand, set
the 'ArrayValued' option to true.
Error in integralCalc/iterateScalarValued (line 315)
finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
515 error(message('MATLAB:integral:FxNotSameSizeAsX'));