Red status bar shown while switching camera using AVFoundation

I am facing very weird issue while switching between camera. When user switch the camera from front to rear, user can see the red status bar for a second then disappears automatically with slide up animation. I searched a lot on google & stack-overflow but no luck. I found this question , but its related to audio recording. Here is my code

    AVCaptureDevicePosition desiredPosition;
    if (isFront) {
        desiredPosition = AVCaptureDevicePositionFront;
        self.videoDeviceType = VideoDeviceTypeFrontCamera;
    else {
        desiredPosition = AVCaptureDevicePositionBack;
        self.videoDeviceType = VideoDeviceTypeRearCamera;

    for (AVCaptureDevice *d in [AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo])
        if ([d position] == desiredPosition)
            AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:d error:nil];
            [self.session beginConfiguration];
            [self.session removeInput:self.videoInput];
            if ([self.session canAddInput:videoDeviceInput])
                [self.session addInput:videoDeviceInput];
                [self setVideoInput:videoDeviceInput];
                [self.session addInput:self.videoInput];
            [self.session commitConfiguration];

Also after camera is switched & try to record the video then below method from AVCaptureVideoDataOutputSampleBufferDelegate not getting called.

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection

Any kind of help is highly appreciated. Thanks.


This red status bar appears due to audio recording, as you've mentioned a question which also describe that this is due to audio recording. In order to avoid this you need to remove the audio input from AVCaptureSession

[self.captureSession removeInput:audioInput];

where audioInput is AVCaptureDeviceInput object.

Please check @bruno answer for more clarification.

Need Your Help

Setting up spring app with spring data repositories and mongo db

java spring mongodb maven

I am facing an issue when defining mongo repository in application-context.xml

jquery conditional logic for currentpage

javascript jquery menu

I'm using jQuery for a vertical site navigation menu, all links within site. I have the basic functionality working, but am at a loss as to the correct if-else to accomplish the following: