我使用不同的主题和灯光进行了一些测试。每个测试都显示标准的iOS相机应用程序质量明显优于我基于自定义AVFoundation的应用程序(颜色不褪色,对焦更好,照明更好,噪点更少)。我无法解释这些巨大的差异。以下是使用两种方法(使用前置摄像头)拍摄的视频的示例屏幕截图。
iOS标准相机应用程序:
自定义AVFoundation录制的视频:
自定义实现的代码:
iOS标准相机应用程序:
![enter image description here](https://istack.dev59.com/yKOWS.webp)
![enter image description here](https://istack.dev59.com/O89bz.webp)
let chosenCameraType = AVCaptureDevicePosition.Front
//get camera
let devices = AVCaptureDevice.devices()
for device in devices
{
if (!device.hasMediaType(AVMediaTypeVideo))
{
continue
}
if (device.position != chosenCameraType)
{
continue
}
camera = (device as? AVCaptureDevice)!
}
do
{
captureSession = AVCaptureSession()
captureSession!.sessionPreset = AVCaptureSessionPresetHigh
let video = try AVCaptureDeviceInput(device: camera) as AVCaptureDeviceInput
captureSession!.addInput(video)
let audio = try AVCaptureDeviceInput(device: AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio)) as AVCaptureDeviceInput
captureSession!.addInput(audio)
fileOutput = AVCaptureMovieFileOutput()
captureSession?.addOutput(fileOutput)
captureSession!.startRunning()
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
let name = String(UInt64(NSDate().timeIntervalSince1970 * 1000))
fileOutput?.startRecordingToOutputFileURL(NSURL(fileURLWithPath: "\(documentsPath)/" + name + ".mov"), recordingDelegate: self)
}
catch let error as NSError
{
print(error)
}
请尝试!你也会看到区别...