Screen quickly flickers black when start recording from front camera
kselvin opened this issue · comments
When I try to record using the front camera the screen quickly flickers before the recording begins.
I am going to assume this is caused by the camera doing sort of configuration right before the filming starts.
If anyone could help me out on this I'd really appreciate it!
I have commented out the metadata capture code in the startRecordingVideo() and it worked for me!
open func startRecordingVideo() {
if cameraOutputMode != .stillImage {
let videoOutput = _getMovieOutput()
// setup video mirroring
for connection in videoOutput.connections {
for port in connection.inputPorts {
if port.mediaType == AVMediaType.video && cameraDevice == CameraDevice.front {
let videoConnection = connection as AVCaptureConnection
if videoConnection.isVideoMirroringSupported {
videoConnection.isVideoMirrored = (cameraDevice == CameraDevice.front && shouldFlipFrontCameraImage)
}
if videoConnection.isVideoStabilizationSupported {
videoConnection.preferredVideoStabilizationMode = self.videoStabilisationMode
}
}
}
}
/*
let specs = [kCMMetadataFormatDescriptionMetadataSpecificationKey_Identifier as String: AVMetadataIdentifier.quickTimeMetadataLocationISO6709,
kCMMetadataFormatDescriptionMetadataSpecificationKey_DataType as String: kCMMetadataDataType_QuickTimeMetadataLocation_ISO6709 as String] as [String : Any]
var locationMetadataDesc: CMFormatDescription?
CMMetadataFormatDescriptionCreateWithMetadataSpecifications(kCFAllocatorDefault, kCMMetadataFormatType_Boxed, [specs] as CFArray, &locationMetadataDesc)
// Create the metadata input and add it to the session.
guard let captureSession = captureSession, let locationMetadata = locationMetadataDesc else {
return
}
let newLocationMetadataInput = AVCaptureMetadataInput(formatDescription: locationMetadata, clock: CMClockGetHostTimeClock())
captureSession.addInputWithNoConnections(newLocationMetadataInput)
// Connect the location metadata input to the movie file output.
let inputPort = newLocationMetadataInput.ports[0]
captureSession.add(AVCaptureConnection(inputPorts: [inputPort], output: videoOutput))
*/
_updateIlluminationMode(flashMode)
videoOutput.startRecording(to: _tempFilePath(), recordingDelegate: self)
} else {
_show(NSLocalizedString("Capture session output still image", comment:""), message: NSLocalizedString("I can only take pictures", comment:""))
}
}
THANK YOU! This worked for me too. I really appreciate it!
@kselvin do you have a piece of code that reproduces this? Thanks.