-
Notifications
You must be signed in to change notification settings - Fork 272
bypassRecord
pengbin edited this page Nov 14, 2016
·
4 revisions
旁路录像是指在开始推流之后, 启动录像可以将推流的视频内容同步保存为本地文件, 也称为边推边录. 目前支持保存为本地的MP4文件和flv文件. 必须要启动推流后才能开始录像, 结束推流时, 会强制停止录像.
在推流的基础类中和启动和停止推流的API, 平行的增加了一组启动和停止旁路录像的API
_bypassRecFile =[NSHomeDirectory() stringByAppendingString:@"/Documents/rec.mp4"];
NSURL *url =[[NSURL alloc] initFileURLWithPath:_bypassRecFile];
[_kit.streamerBase startBypassRecord:url];
// ...
[_kit.streamerBase stopBypassRecord];
- 通过状态属性来查询当前旁路录像的状态
KSYRecordState bypassRecordState;
- 通过状态回调函数来接收状态变化通知
_kit.streamerBase.bypassRecordStateChange = ^(KSYRecordState state) {
[self onBypassRecordStateChange:state];
};
- (void) onBypassRecordStateChange: (KSYRecordState) newState {
if (newState == KSYRecordStateRecording){
NSLog(@"start bypass record");
}
else if (newState == KSYRecordStateStopped) {
NSLog(@"stop bypass record");
[self saveVideoToAlbum:_bypassRecFile];
}
else if (newState == KSYRecordStateError) {
NSLog(@"bypass record error");
}
}
通过如下接口查询, 返回结果是单位为秒的浮点数
_kit.streamerBase.bypassRecordDuration;
注意: 由于是将录像的内容保存在本地, 请注意限制时长, 避免手机存储满.