企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
![](https://img.kancloud.cn/25/1d/251d713b6fb0859666334feeec1cbfe1_301x435.png)在直播页面初始化美颜菜单UI和MHBeautyManager后,即构的美颜与其他SDK稍有不同。首先检查工程中是否有下图的advanced文件以及里面的类文件(After initializing the beauty menu UI and MHBeautyManager on the live broadcast page, the beauty constructed is slightly different from other SDKs. First, check whether there are advanced files and class files in the project)。 如果没有的话,请点击链接下载直播Demo,国内用户推荐码云<https://gitee.com/zegodev/ZegoLiveDemo5Rtp.git> 如果上面的链接无效的话,请去即构官网下载直播Demo。(If not, please go to the official website of instant construction to download the live demo.) 将advanced文件夹和ZegoAVKitManager拷贝到当前工程中。然后需要修改文件(Copy the advanced folder and ZegoAVKitManager to the current project. Then you need to modify the file): - 初始化Zego的时候调用方法(call the method when initializing Zego) ``` [ZegoDemoHelper setRecordTime:YES]; ``` - ZegoAVKitManager.h, Add code: ``` + (void)setBeautyManager:(MHBeautyManager *)beautyManager; ``` - ZegoAVKitManager.m实现这个方法(Implement this method): ``` +(void)setBeautyManager:(MHBeautyManager *)beautyManager { if(g_filterFactory){ [((ZegoVideoFilterFactoryDemo *)g_filterFactory) setBeautyManager:beautyManager]; } } ``` - ZegoVideoFilterDemo.h add ``` #import <MHBeautySDK/MHBeautyManager.h> ``` 按照图示添加红框的代码(Add the code with red box as shown in the figure): ![](https://img.kancloud.cn/8a/ce/8ace3cb58fc1f9fe688dfa9621f84119_1346x1142.png) - ZegoVideoFilterDemo.m : 按照图示在对应的位置添加红框的代码(Add the code of red box at the corresponding position as shown in the figure): ![](https://img.kancloud.cn/5a/57/5a577fde6883c89df2f44ae1f8918ab6_819x709.png) - 渲染方法中添加调用beautyManager的渲染方法(Add a rendering method that calls beautymanager to the rendering method): video\_capture\_external\_demo.h ![](https://img.kancloud.cn/d8/5e/d85e87f49fe50b48fe25b505be8bfaf2_957x645.png) video\_capture\_external\_demo.m : ``` - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { CMTime pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer); CVImageBufferRef buffer = CMSampleBufferGetImageBuffer(sampleBuffer); OSType formatType = CVPixelBufferGetPixelFormatType(pixelBuffer); [_beautyManager processWithPixelBuffer:pixelBuffer formatType:formatType]; } ``` - 销毁beautyManager(destroy beautymanager) ``` - (void)zego_stopAndDeAllocate{ if (_beautyManager) { [_beautyManager destroy]; _beautyManager = nil; } } ```