简体   繁体   中英

GPUImageMovieWriter not recording audio

I saw a previous thread had the same issue but I wanted to see if there are any ideas. I have an app where I take a sequence of photos then an option to record a message pops up. I have my exposure locked but when I go to record a video it unlocks and it doesn't go back to the original state when I am done recording. I moved

self.stillCamera.audioEncodingTarget = self.movieWriter;

to

viewDidLoad

like a previous thread said to do. This fixed the exposure issue but now there is no audio. I am stumped.

Here's some of the code.

(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];
}

Try putting self.stillCamera.audioEncodingTarget = nil; after the call to [self.movieWriter finishRecording]; That's how I have it set up at least.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM