BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.25k stars 4.61k forks source link

setting audioEncodingTarget,background playing music is stoped #2296

Closed zhangxiangguang closed 8 years ago

zhangxiangguang commented 8 years ago

hi, use GPUImageMovieWriter recording video(other music app is background playing), but set audioEncodingTarget is movieWriter, music is stoped, why? set AVAudioSession category is AVAudioSessionCategoryPlayAndRecord not working. multi audio input, output not support? thank you.

zhangxiangguang commented 8 years ago

I resoveled this problem, we must set a property for automaticallyConfiguresApplicationAudioSession as NO before startCameraCapture.

mingyue1991 commented 7 years ago

hi, thanks ,but why it still stoped? can you help me have a look my code here

- (BOOL)startPreviewWithView:(UIView *)view
{
#if !(TARGET_IPHONE_SIMULATOR)
GPUImageCropFilter *defaultFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0, 0, 1, 1)];
[self.filterQueue addObjectSafely:defaultFilter];
GPUImageView *filterView = [[GPUImageView alloc] initWithFrame:view.bounds];
filterView.fillMode = kGPUImageFillModePreserveAspectRatioAndFill;
filterView.tag = 99;
[defaultFilter addTarget:filterView];
self.filterView = filterView;
self.previewView = view;
[view addSubview:filterView];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
self.stillCamera = ({
    AVCaptureDevicePosition posation = [[NSUserDefaults standardUserDefaults] integerForKey:@"WBCCameraViewControllerCameraPositionKey"];
    GPUImageStillCamera *camera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetHigh cameraPosition:posation];
    camera.outputImageOrientation = UIInterfaceOrientationPortrait;
    camera.horizontallyMirrorFrontFacingCamera = YES;
    camera.captureSession.automaticallyConfiguresApplicationAudioSession = NO;
    [camera addAudioInputsAndOutputs];
    camera.delegate = self;
    [camera addTarget:defaultFilter];
    camera;
});
if (self.stillCamera == nil) {//不存在相机
    return NO;
}
self.currentEffectFilterType = -1;
[self applyEffectFilter:0 intensity:100.0];
[self.stillCamera startCameraCapture];
return YES;
#else

return NO;
#endif
}
mingyue1991 commented 7 years ago

and if i setCategory withOption AVAudioSessionCategoryOptionMixWithOthers, the music can still play ,but with a turned down volume,maybe as it mixed.how can some app sound like the same?