当我的应用程序进入后台时,我在将视频从 GPUImage videoCamera 保存到相机胶卷时遇到问题。该文件仅在应用程序返回前台/重新启动时保存到相机胶卷。毫无疑问,我会犯初学者代码错误,如果有人能指出,将不胜感激。
- (void)applicationDidEnterBackground:(UIApplication *)application {
if (isRecording){
[self stopRecording];
};
if (self.isViewLoaded && self.view.window){
[videoCamera stopCameraCapture];
};
runSynchronouslyOnVideoProcessingQueue(^{
glFinish();
});
NSLog(@"applicationDidEnterBackground");
接着
-(void)stopRecording {
[filterBlend removeTarget:movieWriter];
videoCamera.audioEncodingTarget = nil;
[movieWriter finishRecording];
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"file.mov"];
ALAssetsLibrary *al = [[ALAssetsLibrary alloc] init];
[al writeVideoAtPathToSavedPhotosAlbum:[NSURL fileURLWithPath:path] completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@"Error %@", error);
} else {
NSLog(@"Success");
}
}];
isRecording = NO;
NSLog(@"Stop recording");