Предварительный просмотр камеры замораживает на одной кадре (черное/частично отображаемое изображение), а прямая подача камеры никогда не запускается. Пользовательский интерфейс остается отзывчивым, но AvcaptureSession не доставляет кадры после инициализации. По сути, предварительный просмотр показывает несвежая или замороженная рама вместо живого видео. < /P>
func startReceivingUpdates() {
videoFrameService.delegate = self
cameraService.delegate = self
}
func stopReceivingUpdates() {
videoFrameService.delegate = nil
cameraService.delegate = nil
}
< /code>
Они вызываются в Onpear и Ondisappear представления соответственно < /p>
private func configureCaptureSession() {
guard status == .unconfigured else {
return
}
session.beginConfiguration()
defer {
session.commitConfiguration()
}
for input in session.inputs {
session.removeInput(input)
}
let device = AVCaptureDevice.default(
.builtInWideAngleCamera,
for: .video,
position: cameraPosition)
guard let camera = device else {
set(error: .cameraUnavailable)
status = .failed
return
}
do {
let cameraInput = try AVCaptureDeviceInput(device: camera)
if session.canAddInput(cameraInput) {
session.addInput(cameraInput)
} else {
set(error: .cannotAddInput)
status = .failed
return
}
if let audioCaptureDevice = audioCaptureDevice {
let audioInput = try AVCaptureDeviceInput(device: audioCaptureDevice)
if session.canAddInput(audioInput) {
session.addInput(audioInput)
}
}
} catch {
set(error: .createCaptureInput(error))
status = .failed
return
}
session.outputs.forEach { output in
session.removeOutput(output)
}
if session.canAddOutput(videoOutput) {
session.addOutput(videoOutput)
videoOutput.videoSettings =
[kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_32BGRA]
let videoConnection = videoOutput.connection(with: .video)
videoConnection?.videoOrientation = .portrait
videoConnection?.isVideoMirrored = cameraPosition == .front
} else {
set(error: .cannotAddOutput)
status = .failed
return
}
if session.canAddOutput(audioOutput) {
session.addOutput(audioOutput)
}
if session.canAddOutput(photoOutput) {
session.addOutput(photoOutput)
let outputConnection = photoOutput.connection(with: .video)
if cameraPosition == .front {
outputConnection?.automaticallyAdjustsVideoMirroring = false
outputConnection?.isVideoMirrored = true
} else {
outputConnection?.automaticallyAdjustsVideoMirroring = false
outputConnection?.isVideoMirrored = false
}
}
status = .configured
}
< /code>
extension VideoFrameService: AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAudioDataOutputSampleBufferDelegate {
func captureOutput(
_ output: AVCaptureOutput,
didOutput sampleBuffer: CMSampleBuffer,
from connection: AVCaptureConnection
) {
DispatchQueue.main.async {
self.delegate?.update(output: output, sampleBuffer: sampleBuffer)
}
}
}
< /code>
Click to see the image
what will be the root cause for this. and how to solve this
Подробнее здесь: https://stackoverflow.com/questions/797 ... howing-liv
Предварительный просмотр камеры AvcaptureSession FRESTIONS на одном кадре вместо того, чтобы показывать живое видео ⇐ IOS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Предварительный просмотр камеры Android и видео записи MedieareCorder
Anonymous » » в форуме Android - 0 Ответы
- 6 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Предварительный просмотр камеры Android и видео записи MedieareCorder
Anonymous » » в форуме Android - 0 Ответы
- 2 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Что такое пресет AVCaptureSession.Preset.photo для основной камеры iPhone 14/15 Pro/Max 48MP?
Anonymous » » в форуме IOS - 0 Ответы
- 166 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Что такое пресет AVCaptureSession.Preset.photo для основной камеры iPhone 14/15 Pro/Max 48MP?
Anonymous » » в форуме IOS - 0 Ответы
- 142 Просмотры
-
Последнее сообщение Anonymous
-