TXUGCRecord Class Reference
Inherits from | NSObject |
---|---|
Declared in | TXUGCRecord.h |
Other Methods
recordDelegate
视频录制的委托对象,可以获取录制进度等
@property (nonatomic, weak) id<TXUGCRecordListener> recordDelegate
See Also
Declared In
TXUGCRecord.h
videoProcessDelegate
视频画面处理的委托对象,可以获取视频画面的OpenGL纹理ID
@property (nonatomic, weak) id<TXVideoCustomProcessDelegate> videoProcessDelegate
See Also
Declared In
TXUGCRecord.h
partsManager
多段录制的管理
@property (nonatomic, strong, readonly) TXUGCPartsManager *partsManager
See Also
Declared In
TXUGCRecord.h
实例化
摄像头,麦克风相关逻辑
– startCameraSimple:preview:
开始画面预览
- (int)startCameraSimple:(TXUGCSimpleConfig *)config preview:(UIView *)preview
Parameters
config |
预览参数 |
---|---|
preview |
预览画面的父view |
Return Value
0 成功, -1 摄像头尚未关闭 请先调用stopCameraPreview关闭, -2 编码器初始化失败
See Also
Declared In
TXUGCRecord.h
– startCameraCustom:preview:
开始画面预览
- (int)startCameraCustom:(TXUGCCustomConfig *)config preview:(UIView *)preview
Parameters
config |
预览参数 |
---|---|
preview |
预览画面的父vie |
Return Value
0 成功, -1 摄像头尚未关闭 请先调用stopCameraPreview关闭, -2 编码器初始化失败
See Also
Declared In
TXUGCRecord.h
– setVideoResolution:
切换视频录制分辨率,startCamera 之后调用有效 注意:需要在startRecord 之前设置,录制过程中设置无效
- (void)setVideoResolution:(TXVideoResolution)resolution
Parameters
resolution |
视频分辨率 |
---|
Declared In
TXUGCRecord.h
– setVideoRenderMode:
设置视频渲染模式,startCamera 之后调用有效
- (void)setVideoRenderMode:(TXVideoRenderMode)renderMode
Parameters
renderMode |
渲染模式 |
---|
Declared In
TXUGCRecord.h
– setVideoBitrate:
切换视频录制码率 注意:需要在startRecord 之前设置,录制过程中设置无效
- (void)setVideoBitrate:(int)bitrate
Parameters
bitrate |
视频码率 |
---|
Declared In
TXUGCRecord.h
– setZoom:
调整焦距,startCamera 之后调用有效
- (void)setZoom:(CGFloat)distance
Parameters
distance |
取值范围 1~5 ,当为1的时候为最远视角(正常镜头),当为5的时候为最近视角(放大镜头),这里最大值推荐为5,超过5后视频数据会变得模糊不清 |
---|
Declared In
TXUGCRecord.h
– switchCamera:
切换前后摄像头,startCamera 之后调用有效
- (BOOL)switchCamera:(BOOL)isFront
Parameters
isFront |
YES 切换到前置摄像头, NO 切换到后置摄像头 |
---|
Return Value
YES 切换成功, NO 切换失败。
Declared In
TXUGCRecord.h
– toggleTorch:
打开闪关灯,startCamera 之后调用有效
- (BOOL)toggleTorch:(BOOL)enable
Parameters
enable |
YES, 打开 NO, 关闭. |
---|
Return Value
YES 打开成功, NO 打开失败。
Declared In
TXUGCRecord.h
– setHomeOrientation:
设置横竖屏录制,设置后可能会改变视频预览的方向,请调用setRenderRotation 来修本地视预览频流方向,请参考上面注释或则demo示例
- (void)setHomeOrientation:(TXVideoHomeOrientation)homeOrientation
Parameters
homeOrientation |
横竖屏录制方向 |
---|
Discussion
Warning: 需要在startRecord 之前设置,录制过程中设置无效
See Also
Declared In
TXUGCRecord.h
– setRenderRotation:
- 设置预览视频方向
- @param rotation 取值为 0 , 90, 180, 270(其他值无效) 表示视频预览向右旋转的角度 设置横竖屏录制,activty旋转可能会改变视频预览的方向,可以设置此参数让视频预览回到正方向,请参考上面注释或则demo示例
- @warning 需要在 startRecord 之前设置,录制过程中设置无效
- (void)setRenderRotation:(int)rotation
Declared In
TXUGCRecord.h
– setAspectRatio:
设置视频录制比例
- (void)setAspectRatio:(TXVideoAspectRatio)videoRatio
Parameters
videoRatio |
: 3:4 9:16 1:1 |
---|
Discussion
Warning: 需要在 startRecord 之前设置,录制过程中设置无效
Declared In
TXUGCRecord.h
– setRecordSpeed:
设置录制速率 [精简版不支持]
- (void)setRecordSpeed:(TXVideoRecordSpeed)recordSpeed
Declared In
TXUGCRecord.h
– startRecord
开始录制短视频,SDK内部会自动生成视频路经,在TXVideoRecordListener里面返回
- (int)startRecord
Return Value
返回值 | 涵义 |
---|---|
-1 | 正在录制短视频 |
-2 | videoRecorder初始化失败 |
-3 | 摄像头没有打开 |
-4 | 麦克风没有打开 |
-5 | licence 验证失败,您可以通过 getLicenceInfo 接口查询licence信息, |
-6 | videoPath 为nil |
-7 | coverPath 为nil |
Discussion
Warning: 这个接口SDK会自动管理生成的视频和封面,在下次调用startRecord的时候,SDK会自动删除上一次生成的视频和封面
Declared In
TXUGCRecord.h
– startRecord:coverPath:
开始录制短视频
- (int)startRecord:(NSString *)videoPath coverPath:(NSString *)coverPath
Parameters
videoPath |
视频文件输出路径 |
---|---|
coverPath |
封面文件输出路径 |
Discussion
Warning: 这个接口客户需要自己管理生成的视频和封面,在不需要视频和封面的时候自行删除 @return 返回值 | 涵义 ——|—— -1 | 正在录制短视频 -2 | videoRecorder初始化失败 -3 | 摄像头没有打开 -4 | 麦克风没有打开 -5 | licence 验证失败,您可以通过 getLicenceInfo 接口查询licence信息, -6 | videoPath 为nil -7 | coverPath 为nil
Declared In
TXUGCRecord.h
– startRecord:videoPartsFolder:coverPath:
开始录制短视频
- (int)startRecord:(NSString *)videoPath videoPartsFolder:(NSString *)videoPartsFolder coverPath:(NSString *)coverPath
Parameters
videoPath |
视频文件输出路径 |
---|---|
videoPartsFolder |
分片视频存储目录 |
coverPath |
封面文件输出路径 |
Discussion
Warning: 这个接口客户需要自己管理生成的视频和封面,在不需要视频和封面的时候自行删除 @return 返回值 | 涵义 ——|—— -1 | 正在录制短视频 -2 | videoRecorder初始化失败 -3 | 摄像头没有打开 -4 | licence 验证失败,您可以通过 getLicenceInfo 接口查询licence信息, -6 | videoPath 为nil -7 | coverPath 为nil
Declared In
TXUGCRecord.h
– pauseRecord
暂停录制短视频(注:切后台时需保持后台运行状态) 每一次暂停录制都会生成一个视频片段(>100ms有效,<= 100ms 会被认为是无效视频,不会被存放在视频分片里面),您可以在partsManager里面管理这些视频片段
- (int)pauseRecord
Return Value
0 成功, -1 不存在录制任务, -2 videoRecorder未初始化
Declared In
TXUGCRecord.h
– pauseRecord:
4.9 版本后pauseRecord 修改为了异步调用,请在收到 complete 回调后再去 partsManager 获取当前的视频片段信息 注意:resumeRecord 不需要等到 pauseRecord 的 complete 之后再调用,正常顺序调用即可
- (int)pauseRecord:(void ( ^ ) ( void ))complete
Return Value
0 成功, -1 不存在录制任务, -2 videoRecorder未初始化
Declared In
TXUGCRecord.h
– resumeRecord
恢复录制短视频
- (int)resumeRecord
Return Value
0 成功, -1 不存在录制任务, -2 videoRecorder未初始化
Declared In
TXUGCRecord.h
– stopRecord
结束录制短视频,SDK会合成所有视频分片,生成最终视频
- (int)stopRecord
Return Value
0 成功, -1 不存在录制任务, -2 videoRecorder未初始化
Discussion
Warning: 生成最终视频后,当您不再使用录制过程中的生成的视频分片,请主动调用TXUGCPartsManager -> deleteAllParts 删除,否则视频分片会一直存在本地,如果程序没有重启,下次录制SDK也会默认加载当前视频分片
Declared In
TXUGCRecord.h
– pauseAudioSession
在录制的过程中,如果您使用了其他播放器预览视频,AudioSession可能会冲突,会导致录制/播放异常,因此, 当使用其他播放器预览视频的时候,请先调用 pauseAudioSession 当停止视频预览,重新录制的时候,请调用 resumeAudioSession
- (void)pauseAudioSession
Declared In
TXUGCRecord.h
录制效果设置相关逻辑
– setWaterMark:normalizationFrame:
设置全局水印 [精简版不支持]
- (void)setWaterMark:(UIImage *)waterMark normalizationFrame:(CGRect)normalizationFrame
Parameters
waterMark |
全局水印图片 @prarm normalizationFrame 水印相对于视频图像的归一化frame,x,y,width,height 取值范围 0~1; height不用设置,sdk内部会根据水印宽高比自动计算height; 比如视频图像大小为(540,960) frame设置为(0.1,0.1,0.1,0),水印的实际像素坐标为(540 * 0.1,960 * 0.1,540 * 0.1 ,540 * 0.1 * waterMark.size.height / waterMark.size.width) |
---|
Declared In
TXUGCRecord.h
– setBeautyStyle:beautyLevel:whitenessLevel:ruddinessLevel:
设置美颜 和 美白 效果级别
- (void)setBeautyStyle:(TXVideoBeautyStyle)beautyStyle beautyLevel:(float)beautyLevel whitenessLevel:(float)whitenessLevel ruddinessLevel:(float)ruddinessLevel
Parameters
beautyStyle |
: 美颜风格,TXVideoBeautyStyle类型。 |
---|---|
beautyLevel |
: 美颜级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
whitenessLevel |
: 美白级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
ruddinessLevel |
: 红润级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
Declared In
TXUGCRecord.h
– setFilter:
设置指定素材滤镜特效 demo 用到的滤镜查找表图片位于RTMPiOSDemo/RTMPiOSDemo/resource/FilterResource.bundle中
- (void)setFilter:(UIImage *)filterImage
Parameters
filterImage |
指定素材,即颜色查找表图片。注意:一定要用png格式!!! |
---|
Declared In
TXUGCRecord.h
– setFilter:leftIntensity:rightFilter:rightIntensity:leftRatio:
设置两个滤镜效果 [精简版不支持]
- (void)setFilter:(UIImage *)leftFilter leftIntensity:(CGFloat)leftIntensity rightFilter:(UIImage *)rightFilter rightIntensity:(CGFloat)rightIntensity leftRatio:(CGFloat)leftRatio
Parameters
leftFilter |
左滤镜图片(nil代表无左滤镜效果) |
---|---|
leftIntensity |
左滤镜浓度 |
rightFilter |
右滤镜图片(nil代表无右滤镜效果) |
rightIntensity |
右滤镜浓度 |
leftRatio |
左滤镜所占比例 |
Declared In
TXUGCRecord.h
– setSpecialRatio:
设置滤镜效果程度
- (void)setSpecialRatio:(float)specialRatio
Parameters
specialRatio |
从0到1,越大滤镜效果越明显,默认取值0.5 |
---|
Declared In
TXUGCRecord.h
– setEyeScaleLevel:
设置大眼级别(增值版本有效,普通版本设置此参数无效) [仅限商业版Pro]
- (void)setEyeScaleLevel:(float)eyeScaleLevel
Parameters
eyeScaleLevel |
大眼级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXUGCRecord.h
– setFaceScaleLevel:
设置瘦脸级别(增值版本有效,普通版本设置此参数无效)[仅限商业版Pro]
- (void)setFaceScaleLevel:(float)faceScaleLevel
Parameters
faceScaleLevel |
瘦脸级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXUGCRecord.h
– setFaceVLevel:
设置V脸(增值版本有效,普通版本设置此参数无效)[仅限商业版Pro]
- (void)setFaceVLevel:(float)faceVLevel
Parameters
faceVLevel |
V脸级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXUGCRecord.h
– setChinLevel:
设置下巴拉伸或收缩(增值版本有效,普通版本设置此参数无效)[仅限商业版Pro]
- (void)setChinLevel:(float)chinLevel
Parameters
chinLevel |
下巴拉伸或收缩取值范围 -9 ~ 9; 0 表示关闭 -9收缩 ~ 9拉伸。 |
---|
Declared In
TXUGCRecord.h
– setFaceShortLevel:
设置短脸(增值版本有效,普通版本设置此参数无效)[仅限商业版Pro]
- (void)setFaceShortLevel:(float)faceShortlevel
Parameters
faceShortlevel |
短脸级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXUGCRecord.h
– setNoseSlimLevel:
设置瘦鼻(增值版本有效,普通版本设置此参数无效)[仅限商业版Pro]
- (void)setNoseSlimLevel:(float)noseSlimLevel
Parameters
noseSlimLevel |
瘦鼻级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXUGCRecord.h
– setGreenScreenFile:
设置绿幕文件(增值版本有效,普通版本设置此参数无效)[仅限商业版Pro]
- (void)setGreenScreenFile:(NSURL *)file
Parameters
file |
绿幕文件路径 |
---|
Declared In
TXUGCRecord.h
– selectMotionTmpl:inDir:
设置动效 (增值版本有效,普通版本设置此参数无效)[仅限商业版及商业版Pro]
- (void)selectMotionTmpl:(NSString *)tmplName inDir:(NSString *)tmplDir
Parameters
tmplName |
动效名称 |
---|---|
tmplDir |
动效上层文件路径 |
Declared In
TXUGCRecord.h
– setMotionMute:
设置动效静音 (增值版本有效,普通版本设置此参数无效)[仅限商业版及商业版Pro]
- (void)setMotionMute:(BOOL)motionMute
Parameters
motionMute |
YES 静音, NO 不静音 |
---|
Declared In
TXUGCRecord.h
背景音相关逻辑
– setBGM:
设置背景音乐文件 [精简版不支持] 注意:录制过程不能切换背景音乐,可能会导致异常,如果需要切换音乐,请先停止视频录制
- (CGFloat)setBGM:(NSString *)path
Parameters
path |
音乐文件路径,一定要是app对应的document目录下面的路径,否则文件会读取失败 return: 音乐时长 s (返回值为0,表示BGM格式不支持或则音频解析失败) |
---|
Declared In
TXUGCRecord.h
– setBGMAsset:
设置背景音乐文件 [精简版不支持] 注意:录制过程不能切换背景音乐,可能会导致异常,如果需要切换音乐,请先停止视频录制
- (CGFloat)setBGMAsset:(AVAsset *)asset
Parameters
asset |
音乐属性asset,从系统媒体库loading出来的音乐,可以直接传入对应的音乐属性,会极大的降低音乐从系统媒体库loading的时间,具体请参考demo用法 return: 音乐时长 s (返回值为0,表示BGM格式不支持或则音频解析失败) |
---|
Declared In
TXUGCRecord.h
– setBGMLoop:
设置背景音乐是否循环播放 [精简版不支持]
- (void)setBGMLoop:(BOOL)isLoop
Parameters
isLoop |
是否循环播放 |
---|
Declared In
TXUGCRecord.h
– playBGMFromTime:toTime:withBeginNotify:withProgressNotify:andCompleteNotify:
播放背景音乐 [精简版不支持] 必须在startCamera之后调用
- (BOOL)playBGMFromTime:(float)startTime toTime:(float)endTime withBeginNotify:(void ( ^ ) ( NSInteger errCode ))beginNotify withProgressNotify:(void ( ^ ) ( NSInteger progressMS , NSInteger durationMS ))progressNotify andCompleteNotify:(void ( ^ ) ( NSInteger errCode ))completeNotify
Parameters
startTime |
音乐播放起始时间 |
---|---|
endTime |
音乐播放结束时间 |
beginNotify |
音乐播放开始的回调 |
progressNotify |
音乐播放的进度回调,单位毫秒 |
completeNotify |
音乐播放结束的回调 |
Return Value
是否成功
Declared In
TXUGCRecord.h
– setMicVolume:
设置麦克风的音量大小,播放背景音乐混音时使用,用来控制麦克风音量大小 [精简版不支持]
- (BOOL)setMicVolume:(float)volume
Parameters
volume |
音量大小,1为正常音量,建议值为0~2,如果需要调大音量可以设置更大的值 注意:这个接口目前在playBGM之后才生效 |
---|
Declared In
TXUGCRecord.h
– setBGMVolume:
设置背景音乐的音量大小,播放背景音乐混音时使用,用来控制背景音音量大小 [精简版不支持]
- (BOOL)setBGMVolume:(float)volume
Parameters
volume |
音量大小,1为正常音量,建议值为0~2,如果需要调大背景音量可以设置更大的值 注意:这个接口目前在playBGM之后才生效 |
---|
Declared In
TXUGCRecord.h
– setReverbType:
设置混响效果 [精简版不支持]
- (BOOL)setReverbType:(TXVideoReverbType)reverbType
Parameters
reverbType |
混响类型 ,详见 TXReverbType |
---|
Declared In
TXUGCRecord.h
– setVoiceChangerType:
设置变声类型 [精简版不支持]
- (BOOL)setVoiceChangerType:(TXVideoVoiceChangerType)voiceChangerType
Parameters
voiceChangerType |
变声类型, 详见 TXVoiceChangerType 注意:变声目前仅支持 AUDIO_SAMPLERATE_8000 , AUDIO_SAMPLERATE_16000 ,AUDIO_SAMPLERATE_48000 三种采样率 |
---|
Declared In
TXUGCRecord.h
– snapshot:
- 截图/拍照,startCamera 之后调用有效 [精简版不支持]
- (int)snapshot:(void ( ^ ) ( UIImage *))snapshotCompletionBlock
Parameters
snapshotCompletionBlock |
完成回调 @return 0 | 成功 -2 | videoRecorder初始化失败 -5 | licence 验证失败,您可以通过 getLicenceInfo 接口查询licence信息 |
---|
Declared In
TXUGCRecord.h