AliyunIRecorder
@interface AliyunIRecorder : NSObject
录制类,提供录制能力,短视频的核心类之一
-
预览视图
必须设置
Declaration
Objective-C
@property(nonatomic, strong) UIView *preview
-
视频的输出路径
必须设置
Declaration
Objective-C
@property (nonatomic, copy) NSString *outputPath;
-
taskPath文件夹路径
需要保证文件夹已经创建,必须设置
Declaration
Objective-C
@property (nonatomic, copy) NSString *taskPath;
-
Delegate
Declaration
Objective-C
@property (nonatomic, weak) id<AliyunIRecorderDelegate> delegate;
-
美颜状态是否开启
Declaration
Objective-C
@property (nonatomic) BOOL beautifyStatus;
-
设置美颜度 [0,100]
Declaration
Objective-C
@property (nonatomic) int beautifyValue;
-
曝光值 [0,1]
Declaration
Objective-C
@property (nonatomic) CGFloat exposureValue;
-
前置摄像头采集分辨率
默认:AVCaptureSessionPreset640x480 更多参数参见:AVCaptureSession.h
Declaration
Objective-C
@property (nonatomic, copy) NSString *frontCaptureSessionPreset;
-
后置摄像头采集分辨率
默认:AVCaptureSessionPreset1280x720 更多参数参见:AVCaptureSession.h
Declaration
Objective-C
@property (nonatomic, copy) NSString *backCaptureSessionPreset;
-
摄像头角度
Declaration
Objective-C
@property (nonatomic) int cameraRotate;
-
手动对焦点,相对预览视图的位置
Declaration
Objective-C
@property (nonatomic) CGPoint focusPoint;
-
调整变焦倍数
每次调用videoZoomFactor,实际变焦值zoom为设定的1/100 例:调用videoZoomFactor = 10.0f,实际zoom += 0.1f 例:调用videoZoomFactor = -5.0f,实际zoom -= 0.05f
Declaration
Objective-C
@property (nonatomic) CGFloat videoZoomFactor;
-
设置前置摄像头是否支持调整变焦,后置摄像头默认支持变焦,前置摄像头默认不支持变焦 当supportVideoZoomFactorForFrontCamera = YES时,前置摄像头支持变焦
Declaration
Objective-C
@property (nonatomic) BOOL frontCameraSupportVideoZoomFactor;
-
录制的视频是否左右翻转
Declaration
Objective-C
@property (nonatomic) BOOL videoFlipH;
-
编码方式
0软编 1硬编 iOS强制硬编
Declaration
Objective-C
@property (nonatomic) int encodeMode;
-
关键帧间隔,有效区间[0, 9000],其中0和1都表示全I帧
默认5
Declaration
Objective-C
@property (nonatomic) int GOP;
-
录制帧率, 取值区间(0,30],区间外的值将视为无效值,依然使用默认值。
默认25
Declaration
Objective-C
@property (nonatomic) int recordFps;
-
是否静音
添加音乐后,静音无效
Declaration
Objective-C
@property (nonatomic) BOOL mute;
-
视频质量,设置bitrate参数后,该参数无效
Declaration
Objective-C
@property (nonatomic) AliyunVideoQuality videoQuality;
-
输出视频码率 bps 最小值200000bps 最大值20000000bps
Declaration
Objective-C
@property (nonatomic) int bitrate;
-
提供三种格式:如果设置不是此三值,将会视情况分配此三种格式中的一种 kCVPixelFormatType_420YpCbCr8BiPlanarFullRange, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, kCVPixelFormatType_32BGRA, 默认kCVPixelFormatType_420YpCbCr8BiPlanarFullRange格式
Declaration
Objective-C
@property (nonatomic) AliyunIRecorderVideoOutputPixelFormatType outputType;
-
是否开启人脸识别
使用自带人脸识别,开启该功能,系统会在检测到有人脸动图加入时自动进行追踪显示
Declaration
Objective-C
@property (nonatomic) BOOL useFaceDetect;
-
设置识别人脸的个数 当设置值小于1时,默认为1;当设置值大于3时,默认为3
最大是3个 最小是1个 如果不需要检测人脸 使用:useFaceDetect = NO
Declaration
Objective-C
@property (nonatomic) int faceDetectCount;
-
是否同步贴合人脸
同步贴合人脸动图会在同步线程执行,优点是贴合性强,缺点是性能差的设备会有卡顿现象 非同步贴合人脸动图,有点是画面流畅但贴图贴合性不强 默认是YES,6及以下机型建议异步,6以上建议同步
Declaration
Objective-C
@property (nonatomic) BOOL faceDectectSync;
-
设备权限
包括麦克风和摄像头权限
Declaration
Objective-C
@property (nonatomic, readonly) AliyunIRecorderDeviceAuthor authorizationStatus;
-
手电筒是否可用
Declaration
Objective-C
@property (nonatomic, readonly) BOOL hasTorch;
-
电筒模式
Declaration
Objective-C
@property (nonatomic, readonly) AliyunIRecorderTorchMode torchMode;
-
获取摄像头位置
Declaration
Objective-C
@property (nonatomic, readonly) AliyunIRecorderCameraPosition cameraPosition;
-
获取最大变焦系数
Declaration
Objective-C
@property (nonatomic, readonly) CGFloat videoMaxZoomFactor;
-
是否正在录制
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isRecording;
-
获取视频片段管理器
Declaration
Objective-C
@property (nonatomic, strong, readonly) AliyunClipManager *clipManager;
-
Deprecated
3.19.0废弃
录音是否使用AVAudioSessionModeVideoRecording模式,默认YES
Declaration
Objective-C
@property (nonatomic) BOOL useAudioSessionModeVideoRecording;
-
获取版本号
Declaration
Objective-C
+ (NSString *)version;
Return Value
版本号
-
初始化
Declaration
Objective-C
- (instancetype)initWithDelegate:(id<AliyunIRecorderDelegate>)delegate videoSize:(CGSize)videoSize;
Parameters
delegate
代理
videoSize
视频分辨率,必须为偶数,不能是奇数,不能使用屏幕分辨率 建议使用的分辨率 320*480,540*960,720*1280
Return Value
AliyunIRecorder 对象
-
开始预览
Declaration
Objective-C
- (void)startPreviewWithPositon:(AliyunIRecorderCameraPosition)cameraPosition;
Parameters
cameraPosition
摄像头位置(前置、后置)
-
开始预览 默认前置摄像头
Declaration
Objective-C
- (void)startPreview;
-
停止预览
Declaration
Objective-C
- (void)stopPreview;
-
改变视频分辨率
Declaration
Objective-C
- (void)reStartPreviewWithVideoSize:(CGSize)videoSize;
Parameters
videoSize
视频分辨率
-
开始录制
Declaration
Objective-C
- (int)startRecording;
-
停止录制
是否已停止以回调为准
Declaration
Objective-C
- (void)stopRecording;
-
完成录制
是否完成以回调为准
Declaration
Objective-C
- (void)finishRecording;
-
结束录制,输出给编辑器 API_AVAILABLE(3.23.0) /** Finish record for editor API_AVAILABLE(3.23.0)
Declaration
Objective-C
- (NSString *)finishRecordingForEdit;
-
释放录制资源
Declaration
Objective-C
- (void)destroyRecorder;
-
拍摄一张图片 异步获取
image 采集的渲染后图片 rawImage 采集的原始图片
Declaration
Objective-C
- (void)takePhoto:(void (^)(int *, int *))handler;
-
切换摄像头
Declaration
Objective-C
- (AliyunIRecorderCameraPosition)switchCameraPosition;
Return Value
切换后的摄像头位置
-
循环切换手电筒模式 默认为关 (off —> on —> auto)
Declaration
Objective-C
- (AliyunIRecorderTorchMode)switchTorchMode;
Return Value
切换后的手电筒模式
-
切换为指定手电筒模式
Declaration
Objective-C
- (BOOL)switchTorchWithMode:(AliyunIRecorderTorchMode)torchMode;
Parameters
torchMode
指定模式
Return Value
return YES if success
-
人脸数量的回调
在useFaceDetect开启的状态下生效
Declaration
Objective-C
@property (nonatomic, copy) void (^)(int) faceNumbersCallback;
-
人脸追踪 用户可以选择其他人脸识别库,但是传进来的数据须封装成AliyunFacePoint
Declaration
Objective-C
- (void)faceTrack:(NSArray<AliyunFacePoint *> *)facePoints;
Parameters
facePoints
人脸点数组
-
添加动图
Declaration
Objective-C
- (int)applyPaster:(AliyunEffectPaster *)paster;
Parameters
paster
动图
-
添加滤镜
Declaration
Objective-C
- (int)applyFilter:(AliyunEffectFilter *)filter;
Parameters
filter
滤镜
-
添加动效滤镜
Declaration
Objective-C
- (int)applyAnimationFilter:(AliyunEffectFilter *)filter;
Parameters
filter
滤镜
Return Value
返回值
-
更新动效滤镜
Declaration
Objective-C
- (int)updateAnimationFilter:(AliyunEffectFilter *)filter;
Parameters
filter
滤镜
Return Value
返回值
-
Deprecated
This method will not be supported any more. Do not use it.
添加mv
Declaration
Objective-C
- (int)applyMV:(AliyunEffectMV *)mv;
Parameters
mv
mv
Return Value
返回值 只能在录制开始前调用,录制过程或录制完一段或多段后不能调用该接口 Deprecated 不建议使用的API,未来版本将会移除
-
添加水印
Declaration
Objective-C
- (int)applyImage:(AliyunEffectImage *)image;
Parameters
image
水印
-
添加音乐
Declaration
Objective-C
- (int)applyMusic:(AliyunEffectMusic *)music;
Parameters
music
音乐
Return Value
错误码 只能在录制开始前调用,录制过程或录制完一段或多段后不能调用该接口
-
设置录制速率
Declaration
Objective-C
- (void)setRate:(CGFloat)rate;
Parameters
rate
录制速率 建议0.5-2之间
-
删除效果
Declaration
Objective-C
- (void)deletePaster:(AliyunEffectPaster *)paster;
Parameters
paster
动图
-
删除滤镜
Declaration
Objective-C
- (void)deleteFilter;
-
删除动效滤镜
Declaration
Objective-C
- (void)deleteAnimationFilter;
-
删除水印
Declaration
Objective-C
- (void)deleteImage:(AliyunEffectImage *)image;
Parameters
image
水印
-
设置动图、水印的位置
Declaration
Objective-C
- (void)setEffectView:(CGRect)rect effect:(AliyunEffect *)effect;
Parameters
rect
位置(x,y,width,height)均为比例值 例如播放视频的view的size为(400,400),有动图位置为(50,50,100,100) 则rect参数为(0.125,0.125,0.25,0.25)
effect
指定的效果 (目前支持水印和普通动图)