iOS GPUImage之视频采集GPUImageVideoCamera
生活随笔
收集整理的這篇文章主要介紹了
iOS GPUImage之视频采集GPUImageVideoCamera
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、顏色轉換矩陣
- 標準清晰度:
extern const GLfloat kColorConversion601[]; - 全彩:
extern const GLfloat kColorConversion601FullRange[]; - 高清晰度:
extern const GLfloat kColorConversion709[];
二、片元著色器
- extern NSString *const kGPUImageYUVVideoRangeConversionForRGFragmentShaderString;
- extern NSString *const kGPUImageYUVFullRangeConversionForLAFragmentShaderString;
- extern NSString *const kGPUImageYUVVideoRangeConversionForLAFragmentShaderString;
三、代理
將要輸出的sampleBuffer
@protocol GPUImageVideoCameraDelegate <NSObject> @optional -(void)willOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer; @end四、延展解析
// 已采集的幀數NSUInteger numberOfFramesCaptured;// 采集的總幀數CGFloat totalFrameTimeDuringCapture;// 采集會話層AVCaptureSession *_captureSession;// 視頻輸入設備AVCaptureDevice *_inputCamera;// 音頻輸入設備AVCaptureDevice *_microphone;// 視頻輸入AVCaptureDeviceInput *videoInput;// 視頻數據輸出AVCaptureVideoDataOutput *videoOutput;// 停止采集BOOL capturePaused;// 輸入和輸出旋轉方式GPUImageRotationMode outputRotation, internalRotation;// 幀渲染信號量dispatch_semaphore_t frameRenderingSemaphore;// yuv格式采集BOOL captureAsYUV;// 亮度紋理、色度紋理GLuint luminanceTexture, chrominanceTexture;// 攝像頭采集協議__unsafe_unretained id<GPUImageVideoCameraDelegate> _delegate;五、屬性解析
// 會話層@property(readonly, retain, nonatomic) AVCaptureSession *captureSession;// 采集分辨率@property (readwrite, nonatomic, copy) NSString *captureSessionPreset;// 幀率@property (readwrite) int32_t frameRate;// 前置攝像頭@property (readonly, getter = isFrontFacingCameraPresent) BOOL frontFacingCameraPresent;// 后置攝像頭@property (readonly, getter = isBackFacingCameraPresent) BOOL backFacingCameraPresent;// 基準@property(readwrite, nonatomic) BOOL runBenchmark;// 輸入攝像頭@property(readonly) AVCaptureDevice *inputCamera;// 攝像頭朝向@property(readwrite, nonatomic) UIInterfaceOrientation outputImageOrientation;// 前者攝像頭水平鏡像,后置攝像頭水平鏡像@property(readwrite, nonatomic) BOOL horizontallyMirrorFrontFacingCamera, horizontallyMirrorRearFacingCamera;// 攝像頭代理@property(nonatomic, assign) id<GPUImageVideoCameraDelegate> delegate;六、方法說明
// 根據分辨率、攝像頭朝向初始化攝像頭-(id)initWithSessionPreset:(NSString *)sessionPreset cameraPosition:(AVCaptureDevicePosition)cameraPosition;// 添加音頻的輸入和輸出-(BOOL)addAudioInputsAndOutputs;// 移除音頻的輸入和輸出-(BOOL)removeAudioInputsAndOutputs;// 移除輸入和輸出設備-(void)removeInputsAndOutputs;// 開始采集-(void)startCameraCapture;// 停止采集-(void)stopCameraCapture;// 暫停采集-(void)pauseCameraCapture;// 恢復采集-(void)resumeCameraCapture;// 處理視頻數據-(void)processVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer;// 處理音頻數據-(void)processAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer;// 攝像頭位置(前置/后置)-(AVCaptureDevicePosition)cameraPosition;// 視頻連接-(AVCaptureConnection *)videoCaptureConnection;// 轉換攝像頭-(void)rotateCamera;// 平均幀時長-(CGFloat)averageFrameDurationDuringCapture;- (void)resetBenchmarkAverage;+ (BOOL)isBackFacingCameraPresent;+ (BOOL)isFrontFacingCameraPresent;總結
以上是生活随笔為你收集整理的iOS GPUImage之视频采集GPUImageVideoCamera的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OpenGL ES之深入解析如何实现“手
- 下一篇: iOS之深入解析类Class的底层原理