- 建立AVCaptureInput:AVCaptrueDeviceInput
- 建立AVCaptureOutput:AVCaptureStillImageOutput、AVCaptureMovieFileOutput
- 建立session:AVCaptrueSessuon
- 串連input、output與session
- 建立AVCaptureVideoPreviewLayer,並與session串聯
- 將AVCaptureVideoPreviewLayer加到要預覽的view裡面的layer
- 透過[session startRunning],將預覽畫面顯示到previewLayer上
- 錄影的前置設定完成
二、錄影進行
- connection是input、output與session之間的橋梁,先取得介於output與session之間的connection,並設定錄影水平方向
- 執行AVCaptureOutput的startRecordingToOutputFileURL:recordingDelegate:
- AVCaptureOutput 的isRecording會變成YES
- AVCaptureOutputinstance的AVCaptureOutput
其他附註
取得所有裝置
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];過濾出所要的裝置
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *device in devices) {
if ([device position] == position) {
return device;
}
}
return nil;
取得裝置清單
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
- (AVCaptureDevice *) cameraWithPosition:(AVCaptureDevicePosition) position
{
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *device in devices) {
if ([device position] == position) {
return device;
}
}
return nil;
}
Torch mode
Torch mode is where a camera uses the flash continuously at a low power to illuminate a video capture. There are three torch modes:
AVCaptureTorchModeOff: the torch is always off.AVCaptureTorchModeOn: the torch is always on.AVCaptureTorchModeAuto: the torch is switched on and off as needed.
You use
hasTorch to determine whether a device has a flash. You use the isTorchModeSupported: method to determine whether a device supports a given flash mode, then set the mode using the torchMode property.
For devices with a torch, the torch only turns on if the device is associated with a running capture session.
取得音源裝置
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio];
沒有留言:
張貼留言