-
Notifications
You must be signed in to change notification settings - Fork 271
diyCamera
sunjian880928 edited this page Aug 2, 2016
·
9 revisions
用户可以自己采集音视频数据,使用金山云SDK推流模块,完成推流功能时,可以进行如下配置。
原始数据:使用AVFoundation框架,提供的基本类AVCaptureDeviceInput,AVCaptureSession,AVCaptureVideoDataOutput,AVCaptureAudioDataOutput完成时音频的采集和输出,通过AVCaptureVideoDataOutputSampleBufferDelegate,AVCaptureAudioDataOutputSampleBufferDelegate代理
-(void) captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {}来完成音视频数据输出;
推流模块基本配置:
- 构造推流实例
_gpuStreamer = [[KSYGPUStreamer alloc] initWithDefaultCfg];
- 日志回调
_gpuStreamer.streamerBase.logBlock = ^(NSString *string){
NSLog(@"logBlock: %@", string);
};
- 参数配置
_gpuStreamer.streamerBase.videoCodec = KSYVideoCodec_X264;//编码方式
_gpuStreamer.streamerBase.videoFPS = frameRate;//视频帧率
_gpuStreamer.streamerBase.audiokBPS = 48; // 音频码率
_gpuStreamer.streamerBase.enAutoApplyEstimateBW = YES/NO;//是否开启码率自适应
_gpuStreamer.streamerBase.videoInitBitrate = 600; // k bit ps//初始码率
_gpuStreamer.streamerBase.videoMaxBitrate = 1000; // k bit ps//最大码率
_gpuStreamer.streamerBase.videoMinBitrate = 0; // k bit ps//最小码率
- 开始推流
[_gpuStreamer.streamerBase startStream: _hostURL];//_hostURL为推流地址
[_gpuStreamer.streamerBase stopStream];
- 结束推流
[_gpuStreamer.streamerBase stopStream];