不仅仅是一对一直播系统,其他直播平台、短视频平台对美颜功能的需求都非常的大,今天我们针对一对一直播的美颜预设功能来说一下相关的代码解决方式。此功能主要适用于播端预先设置好美颜、美白、美型灯功能,一对一直播系统进行连麦时直接使用预设好的美颜进行视频通话
1.一对一直播系统在进入预设界面后,首先会获取有没有预设过美颜的值:

-(void)requestSetBeauty{[YBToolClass postNetworkWithUrl:@"user.getBeauty" andParameter:@{@"uid":[Config getOwnID],@"token":[Config getOwnToken]} success:^(int code, id  _Nonnull info, NSString * _Nonnull msg) {NSLog(@"info---------:%@", info);NSDictionary *infos = [info firstObject];_normalMYDic = [infos valueForKey:@"moren"];_xxMYDic = [infos valueForKey:@"meihu"];if ([YBToolClass checkNull:[common getTISDKKey]]){if ([minstr([_normalMYDic valueForKey:@"ishave"]) isEqual:@"1"]) {_tx_whitening_level = [[_normalMYDic valueForKey:@"preinstall"][@"skin_whiting"] floatValue];_redfacDepth = [[_normalMYDic valueForKey:@"preinstall"][@"skin_tenderness"] floatValue];_tx_beauty_level = [[_normalMYDic valueForKey:@"preinstall"][@"skin_smooth"] floatValue];}}else{if ([minstr([_xxMYDic valueForKey:@"ishave"]) isEqual:@"1"]) {[sproutCommon saveSproutMessage:[_xxMYDic valueForKey:@"preinstall"]];_tx_whitening_level = [[_xxMYDic valueForKey:@"preinstall"][@"skin_whiting"] floatValue];_redfacDepth = [[_xxMYDic valueForKey:@"preinstall"][@"skin_tenderness"] floatValue];_tx_beauty_level = [[_xxMYDic valueForKey:@"preinstall"][@"skin_smooth"] floatValue];_light_level = [[_xxMYDic valueForKey:@"preinstall"][@"brightness"] floatValue];_tx_eye_level = [[_xxMYDic valueForKey:@"preinstall"][@"big_eye"] floatValue];_tx_face_level = [[_xxMYDic valueForKey:@"preinstall"][@"face_lift"] floatValue];_mouse_level = [[_xxMYDic valueForKey:@"preinstall"][@"mouse_lift"] floatValue];_nose_level = [[_xxMYDic valueForKey:@"preinstall"][@"nose_lift"] floatValue];_xiaba_level = [[_xxMYDic valueForKey:@"preinstall"][@"chin_lift"] floatValue];_head_level = [[_xxMYDic valueForKey:@"preinstall"][@"forehead_lift"] floatValue];_meimao_level = [[_xxMYDic valueForKey:@"preinstall"][@"eye_brow"] floatValue];_yanjiao_level = [[_xxMYDic valueForKey:@"preinstall"][@"eye_corner"] floatValue];_yanju_level = [[_xxMYDic valueForKey:@"preinstall"][@"eye_length"] floatValue];_kaiyanjiao_level = [[_xxMYDic valueForKey:@"preinstall"][@"eye_alat"] floatValue];_xiaolian_level = [[_xxMYDic valueForKey:@"preinstall"][@"face_shave"] floatValue];_longnose_level = [[_xxMYDic valueForKey:@"preinstall"][@"lengthen_noselift"] floatValue];}

2.获取数据后开始推流设置

#pragma mark ============设置推流参数,开始推流=============- (void)RTMPush{[self.menuView showMenuView:NO];[self creatUI];//配置推流参数_txLivePushonfig = [[TXLivePushConfig alloc] init];_txLivePushonfig.frontCamera = YES;_txLivePushonfig.enableAutoBitrate = YES;_txLivePushonfig.videoResolution = VIDEO_RESOLUTION_TYPE_360_640 ;//background push_txLivePushonfig.pauseFps = 5;_txLivePushonfig.pauseTime = 300;//耳返_txLivePushonfig.enableAudioPreview = NO;_txLivePushonfig.pauseImg = [UIImage imageNamed:@"pause_publish1.jpg"];_txLivePublisher = [[TXLivePush alloc] initWithConfig:_txLivePushonfig];_txLivePublisher.videoProcessDelegate = self;_txLivePublisher.delegate = self;if ([YBToolClass checkNull:[common getTISDKKey]]){isTXfiter = YES;[_txLivePublisher setBeautyStyle:0 beautyLevel:_tx_beauty_level whitenessLevel:_tx_whitening_level ruddinessLevel:_redfacDepth];[_txLivePublisher setMirror:YES];}else{isTXfiter = NO;
//        NSString *key = [common getTISDKKey];NSString *key = [YBToolClass decrypt:[common getTISDKKey]];[[MHSDK shareInstance] init:key];//   [self.menuView setupDefaultBeautyAndFaceValueWithIsTX:YES];[_txLivePublisher setMirror:YES];_txLivePublisher.videoProcessDelegate = self;}[_txLivePublisher startPreview:_previewView];
}}[self RTMPush];} fail:^{}];
}

3.创建UI界面、基本界面就是美颜控制按钮、各个预设界面、预览界面

- (void)creatUI{playBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];playBackView.backgroundColor = [UIColor clearColor];playBackView.clipsToBounds = YES;[self.view addSubview:playBackView];playerMask = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];playerMask.hidden = YES;playerMask.backgroundColor = [UIColor blackColor];[playBackView addSubview:playerMask];_previewView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];_previewView.backgroundColor = [UIColor clearColor];_previewView.clipsToBounds = YES;[self.view addSubview:_previewView];UIButton *_returnBtn = [UIButton buttonWithType:0];_returnBtn.frame = CGRectMake(0, 24+statusbarHeight, 40, 40);[_returnBtn setImage:[UIImage imageNamed:@"white_backImg"] forState:0];[_returnBtn addTarget:self action:@selector(doReturn) forControlEvents:UIControlEventTouchUpInside];[_previewView addSubview:_returnBtn];UIButton *saveBtn = [UIButton buttonWithType:0];saveBtn.frame = CGRectMake(_window_width - 55, 24+statusbarHeight, 40, 40);saveBtn.titleLabel.font = [UIFont systemFontOfSize:16];[saveBtn setTitleColor:[UIColor whiteColor] forState:0];[saveBtn setTitle:@"保存" forState:0];[saveBtn addTarget:self action:@selector(bottomButtonClick:) forControlEvents:UIControlEventTouchUpInside];[_previewView addSubview:saveBtn];saveBtn.tag = 10087;UIButton *meiyanBtn = [UIButton buttonWithType:0];meiyanBtn.frame =CGRectMake(_window_width - 70, 104+statusbarHeight , 60, 60);meiyanBtn.titleLabel.font = [UIFont systemFontOfSize:12];[meiyanBtn setTitleColor:[UIColor whiteColor] forState:0];[meiyanBtn setImage:[UIImage imageNamed:@"通话-美颜"] forState:0];[meiyanBtn addTarget:self action:@selector(bottomButtonClick:) forControlEvents:UIControlEventTouchUpInside];meiyanBtn.tag = 10086;[_previewView addSubview:meiyanBtn];self.meihuBtn = meiyanBtn;
}

4.当美颜进行调节时会走美颜sdk回调方法,保存相应的数值,上传到服务器,开播时获取服务器数据进行设置、美颜预设功能成功

-(void)txsliderValueChange:(UISlider*) obj {// todoif (obj.tag == 1) { //美颜_tx_beauty_level = obj.value;[_txLivePublisher setBeautyStyle:0 beautyLevel:_tx_beauty_level whitenessLevel:_tx_whitening_level ruddinessLevel:_redfacDepth];// [_txLivePublisher setBeautyFilterDepth:_beauty_level setWhiteningFilterDepth:_whitening_level];_whiteValueLb.text = [NSString stringWithFormat:@"%d",(int)obj.value];} else if (obj.tag == 0) { //美白_tx_whitening_level = obj.value;[_txLivePublisher setBeautyStyle:0 beautyLevel:_tx_beauty_level whitenessLevel:_tx_whitening_level ruddinessLevel:_redfacDepth];_beautyValueLb.text = [NSString stringWithFormat:@"%d",(int)obj.value];// [_txLivePublisher setBeautyFilterDepth:_beauty_level setWhiteningFilterDepth:_whitening_level];} else if (obj.tag == 2) { //大眼_tx_eye_level = obj.value;[_txLivePublisher setEyeScaleLevel:_tx_eye_level];} else if (obj.tag == 3) { //瘦脸_tx_face_level = obj.value;[_txLivePublisher setFaceScaleLevel:_tx_face_level];} else if (obj.tag == 4) {// 背景音乐音量[_txLivePublisher setBGMVolume:(obj.value/obj.maximumValue)];} else if (obj.tag == 5) { // 麦克风音量[_txLivePublisher setMicVolume:(obj.value/obj.maximumValue)];}else if (obj.tag == 6){//红润_redfacDepth = obj.value;[_txLivePublisher setBeautyStyle:0 beautyLevel:_tx_beauty_level whitenessLevel:_tx_whitening_level ruddinessLevel:_redfacDepth];_redValueLb.text = [NSString stringWithFormat:@"%d",(int)obj.value];}
}

5.把对应的数据上传到服务器保存。预设成功

NSDictionary *dicccc;
if ([YBToolClass checkNull:[common getTISDKKey]]){MYType = @"1";dicccc = @{@"skin_whiting":@(_tx_whitening_level),@"skin_smooth":@(_tx_beauty_level),@"skin_tenderness":@(_redfacDepth),};}else{MYType = @"2";dicccc = @{@"skin_whiting":@(_tx_whitening_level),@"skin_smooth":@(_tx_beauty_level),@"skin_tenderness":@(_redfacDepth),@"eye_brow":@(_meimao_level),@"big_eye":@(_tx_eye_level),@"eye_length":@(_yanju_level),@"eye_corner":@(_yanjiao_level),@"eye_alat":@(_kaiyanjiao_level),@"face_lift":@(_tx_face_level),@"face_shave":@(_xiaolian_level),@"mouse_lift":@(_mouse_level),@"nose_lift":@(_nose_level),@"chin_lift":@(_xiaba_level),@"forehead_lift":@(_head_level),@"lengthen_noseLift":@(_longnose_level),@"brightness":@(_light_level),};}NSString *specsStr =  [self gs_jsonStringCompactFormatForNSArray:dicccc];NSLog(@"设置美颜参数--------%@",specsStr);
[YBToolClass postNetworkWithUrl:@"user.setBeauty" andParameter:@{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"type":MYType,@"preinstall":specsStr} success:^(int code, id  _Nonnull info, NSString * _Nonnull msg) {NSLog(@"info---------:%@", info);[MBProgressHUD showError:msg];
} fail:^{}];

以上就是关于一对一直播系统关于美颜预设功能的相关代码,美颜预设功能的应用能很好的解决主播忘记开美颜的问题,在直播平台、短视频平台上,预设功能同样很受欢迎。
声明:以上内容为云豹科技作者本人原创,未经作者本人同意,禁止转载,否则将追究相关法律责任http://www.yunbaokj.com/news/html/2066.html

一对一直播系统实现美颜预设功能的代码解决方式相关推荐

  1. 一对一直播系统源码开发,礼物打赏中追加、连击等功能的实现

    在一对一直播系统源码开发中,多种礼物打赏方式,才更能吸引用户的眼球,所在礼物打赏功能开发时,要实现追加.连击等功能. 一对一直播系统源码的礼物追加.连击功能是如何实现的呢?首先礼物从左边滑出,做一个连 ...

  2. 如何只需三步搭建一对一直播系统源码

    随着当下直播行业的红火几乎所有的人手机上都安装了直播app,但是呢直播app也包含很多分类,有一对多直播的还有一对一直播系统,这些系统都是通过直播源码搭建起来的,直播系统开发便获得越来越多程序员的关注 ...

  3. 一对一直播系统源码——如何只需三步搭建

    随着广播行业的蓬勃发展的生活几乎所有人安装应用程序,但是主应用程序还包含很多分类,一对多的直播,一个一个系统,这些系统通过生活建立源代码,广播系统开发从程序员获得越来越多的关注,事实上,只要有一个活系 ...

  4. 开源一对一源码,一对一直播系统如何接入码支付

    在一对一直播系统中,用户常会给主播打赏.送礼物,那么,一对一直播系统中必然要有支付功能,除了系统自带的支付宝.微信.支付等,也有的平台会接入四方支付,如"码支付". "码 ...

  5. 一对一直播系统源码,一对一直播系统开发

    做为移动互联网下的新型娱乐模式,直播系统的开发平台可谓是异常的火热,大大小小的直播平台相继出现.经过这两年的发展,很多人早已经对直播行业没有太大的兴趣,.移动互联网时代里,虽然传统的直播仍旧占据了直播 ...

  6. 一对一直播系统源码的开发是推动直播发展的重要一环节

    文/布谷安妮 来源/山东布谷鸟网络 对于直播平台搭建,软件源码的开发,5G技术马上到来,之前遇到的比如延迟.卡顿.掉线等这些情况,都会随着5G时代的带来.源码开发技术的提高完善逐渐消失.一套完整的一对 ...

  7. 一对一直播系统源码的开发是推动直播发展的重要一环节...

    文/布谷安妮 来源/山东布谷鸟网络 对于直播平台搭建,软件源码的开发,5G技术马上到来,之前遇到的比如延迟.卡顿.掉线等这些情况,都会随着5G时代的带来.源码开发技术的提高完善逐渐消失.一套完整的一对 ...

  8. 想了解直播系统开发美颜的原理,先来学习如何用1行代码实现人脸识别

    想了解直播系统开发美颜的原理,先来学习如何用1行代码实现人脸识别 环境搭建: 1. 安装 Ubuntu17.10 > 安装步骤在这里 2. 安装 Python2.7.14 (Ubuntu17.1 ...

  9. 一对一直播源码开发,一对一直播系统开发

    如今,直播市场越发的火热,一对一直播源码也渐渐浮出水面,在直播大火的现在,您是不是也想要一款属于自己的直播平台呢?小编今天为您讲解一款一对一直播源码开发系统语言和媒体处理模块. 首先是系统开发语言 一 ...

最新文章

  1. HDU 6092 Rikka with Subset 思维 递推
  2. 爬虫篇——User-Agent爬取备用及存储
  3. leetcode1052. 爱生气的书店老板(滑动窗口)
  4. js最小化浏览器_「译」解析、抽象语法树(ast) +如何最小化解析时间的5个技巧...
  5. (01)odoo模型中调用窗体动作
  6. 导航栏 UITabBarController等颜色的区别
  7. 舍 bpftrace 而取 systemtap 的代价和思考
  8. Jenkins持续集成环境, 如何自定义 maven 仓库
  9. SQLServer的索引和统计
  10. pythonturtle编程_Python编程小记:turtle库
  11. WordPress小程序源码 社区论坛小程序源码 知识付费商城小程序下载
  12. Linux 下 Android NDK 编译 openssl
  13. 软件测试面试英文自我介绍,软件测试英文面试自我介绍范文
  14. Android应用测速组件实现原理,这篇看完还不懂跟我去摆地摊,全网首发
  15. 怎么把PPT压缩到最小?
  16. MyBatis进行增删改查
  17. MFC界面控件BCGControlBar v33.3 - 可视化管理器和主题更新
  18. Anders Hejlsberg 访谈 .-转载
  19. matlab绘制单摆相图,单摆相图绘制
  20. WPF UI框架界面开发教程(十二)

热门文章

  1. MTI商家如何快速做大做强
  2. effective emacs中文版
  3. 《天猫总裁张勇:2013年天猫要做什么》阅读笔记
  4. 华米智能手表AMAZFIT硬件配置详解 参数规格
  5. CentOS8重启网卡命令
  6. 用Flutter实现一个涂鸦和加水印功能
  7. 团队管理26--任务执行之过程管理
  8. 正确利用手机赚钱,新手操作无压力——必看系列
  9. 蓝桥杯单片机标准模板
  10. Windows跨设备共享怎么用?Win11跨设备共享的方法