1) 設置視頻采集來源為攝像頭(Set video capture source as camera)
聲明以下屬性(Declare the following properties)
```
@property (nonatomic, strong) NECamera *camera;//作為外部攝像頭
@property (nonatomic, assign) BOOL isStop;
@property (nonatomic, strong) LSVideoParaCtxConfiguration* paraCtx;//推流視頻參數設置
```
2) 設置屬性(set a property)
```
- (void)viewWillDisappear:(BOOL)animated {
_isStop = YES;
[super viewWillDisappear:animated];
[NEMediaCaptureEntity sharedInstance].videoParaCtx = paraCtx;
}
```
paraCtx.isUseExternalCapture = YES;//是否使用外部視頻采集,假設使用外部采集時,攝像頭的采集幀率一定要于設置的paraCtx.fps一致,同時碼率要調整為對應的碼率,對應的分辨率也需要調整(Whether to use external video acquisition. If external acquisition is used, the acquisition frame rate of the camera must be different from the set paractx FPS is consistent. At the same time, the code rate should be adjusted to the corresponding code rate, and the corresponding resolution also needs to be adjusted)
3)使用外部視頻采集(Using external video capture)
```
if (streamparaCtx.sLSVideoParaCtx.isUseExternalCapture) {
//1.從外部攝像頭獲取數據
_camera = [[NECamera alloc] initWithCameraPosition:AVCaptureDevicePositionFront captureFormat:kCVPixelFormatType_32BGRA];
_camera.delegate = self;
[_camera startCapture];
}
```
4)在NECameraDelegate的視頻渲染方法中初始化美狐shader(Initialize the Meihu shader in the video rendering method of NECameraDelegate)
//外部采集攝像頭的數據塞回來給SDK推流
```
-(void)didOutputVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer{
if(!_isStop){
CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
OSType formatType = CVPixelBufferGetPixelFormatType(pixelBuffer);
[self.beautyManager processWithRoatePixelBuffer:pixelBuffer formatType:formatType];
}
[self.mediaCapture externalInputSampleBuffer:sampleBuffer];
}
```
- 美狐SDK接入文檔
- Meihu SDK Access Document
- (Untitled)
- 一、基礎描述(Basic description)
- 1. 最新特性 (Latest features)
- 2. 支持平臺 (Support platform)
- 二、集成步驟 (Integration steps)
- 3. 配置工程(Configuration Engineering)
- 4. 使用 MHUI (Use MHUI)
- 5. 騰訊直播 SDK/短視頻SDK (Tencent live SDK / short video SDK)
- 6. 金山直播SDK (Jinshan)
- 7. 七牛直播SDK (Qiniu Live)
- 8. 七牛短視頻SDK (Qiniu ShortVideo)
- 9. Movieous短視頻 (Movieous short Video)
- 10. 即構直播SDK (Zego live)
- 11. 即構實時音視頻SDK(Zego Real time audio and video)
- 12. 新版Zego(即構)實時音視頻(New Zego Real time audio and video)
- 13. 網易直播 (NetEase live)
- 14. 騰訊互動直播 (Tencent interactive live broadcast)
- 15. 騰訊實時音視頻(Tencent real-time audio and video)
- 16. 融云實時音視頻 (SealRTC)
- 17. 聲網視頻通話 (Agora video call)
- 18. 聲網直播 (Agora Live)
- 19. 阿里直播 (Ali Live)
- 20. 阿里音視頻 SDK美顏
- 三、對接說明 (Docking instructions)
- 四、常見問題(common problem)
- 2. 美顏無效果(Beauty has no effect)
- 3. 貼紙下載失敗(Sticker download failed)
- 4. 點擊無法出現美顏菜單頁(The beauty menu page cannot appear after clicking)
- 5. 英文版顯示中文(The beauty menu page cannot appear after clicking)
- 6. 語言切換功能(Language switching function)