企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
1)设置视频采集来源为摄像头 声明以下属性 ``` @property (nonatomic, strong) NECamera *camera;//作为外部摄像头 @property (nonatomic, assign) BOOLisStop; @property (nonatomic, strong) LSVideoParaCtxConfiguration* paraCtx;//推流视频参数设置 ``` 2)设置属性 ``` - (void)viewWillDisappear:(BOOL)animated { _isStop= YES;     [superview WillDisappear:animated]; [NEMediaCaptureEntity sharedInstance].videoParaCtx= paraCtx; } ``` paraCtx.isUseExternalCapture = YES;//是否使用外部视频采集,假设使用外部采集时,摄像头的采集帧率一定要于设置的paraCtx.fps一致,同时码率要调整为对应的码率,对应的分辨率也需要调整 3)使用外部视频采集 ``` if (streamparaCtx.sLSVideoParaCtx.isUseExternalCapture) {             //1.从外部摄像头获取数据             _camera = [[NECamera alloc] initWithCameraPosition:AVCaptureDevicePositionFront captureFormat:kCVPixelFormatType_32BGRA];             _camera.delegate = self;             [_camera startCapture];     } ``` 4)在NECameraDelegate的视频渲染方法中初始化美狐shader ``` //外部采集摄像头的数据塞回来给SDK推流 -(void)didOutputVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer{ if(!_isStop){ CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); OSType formatType = CVPixelBufferGetPixelFormatType(pixelBuffer); [self.beautyManager processWithPixelBuffer:pixelBuffer formatType:formatType];     } [self.mediaCaptureexternalInputSampleBuffer:sampleBuffer]; } ```