GPUImageMovieWriter不录制音频

时间:2013-11-23 03:04:58

标签: ios gpuimage

我看到前一个帖子有同样的问题,但我想知道是否有任何想法。我有一个应用程序,我在其中拍摄一系列照片,然后弹出一个记录消息的选项。我将曝光锁定,但是当我录制视频时,它会解锁,并且当我完成录制时它不会恢复到原始状态。我搬了

self.stillCamera.audioEncodingTarget = self.movieWriter;

viewDidLoad
就像之前的一个帖子说的那样。这解决了暴露问题,但现在没有音频。我很难过。

这是一些代码。

(void)viewDidLoad {
[super viewDidLoad];
self.library = [[ALAssetsLibrary alloc] init];
takephotocolor.hidden = YES;
takephotobw.hidden = YES;
self.stillCamera.audioEncodingTarget = self.movieWriter;

}

(IBAction)StartButtonPressed:(id)sender {
if(!self.transform){

self.transform = [[GPUImageTransformFilter alloc] init];
CATransform3D perspectiveTransform = CATransform3DScale(CATransform3DMakeRotation(0, 0, 0, 1),
                                                        -1, 1, 1);
[self.transform setTransform3D:perspectiveTransform];
}

[self.filter addTarget:self.transform];

self.pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/movie.mov"];
unlink([self.pathToMovie UTF8String]);
NSURL *movieURL = [NSURL fileURLWithPath:self.pathToMovie];
self.movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL        size:CGSizeMake(1024.0, 768.0)];


[self.transform addTarget:self.movieWriter];
 [self.movieWriter startRecording];

btnStart.hidden = YES;
btnStop.hidden = NO;
NSLog(@"START RECORDING");
}

(IBAction)StopButtonPressed:(id)sender {
self.stillCamera.audioEncodingTarget = nil;
[self.movieWriter finishRecording];

[self.filter removeTarget:self.transform];
[self.transform removeAllTargets];
UISaveVideoAtPathToSavedPhotosAlbum(self.pathToMovie, self, nil, nil);

[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(goVideo) userInfo:nil repeats:NO];
}

1 个答案:

答案 0 :(得分:0)

在调用self.stillCamera.audioEncodingTarget = nil;之后尝试放[self.movieWriter finishRecording];这就是我至少设置它的方式。