【項目一 · 直播】 ☞ 3. 推流直播

1、推流

1. 概念

  推流,就是將採集到的音頻,視頻數據經過流媒體協議發送到流媒體服務器。html

2. 推流過程

  • 推流前的工做:採集,處理,編碼壓縮

    

  • 推流中作的工做: 封裝,上傳

    

3. 推流框架介紹

  • LFLiveKit (推薦):由Adobe公司開發。框架已經實現了 後臺錄製、美顏功能,支持H264(視頻編碼)、AAC(音頻編碼)編碼,支持RTMP傳輸協議,動態改變速率,弱網丟幀(網絡慢的狀況下,爲了保證視頻通暢,一般採用丟幀處理)等。
  • LFLiveKit庫裏已經集成GPUImage框架用於美顏功能,GPUImage基於OpenGl開發,純OC語言框架,封裝好了各類濾鏡同時也能夠編寫自定義的濾鏡,其自己內置了多達125種常見的濾鏡效果。

 

  • LiveVideoCoreSDK : 實現了美顏直播和濾鏡功能,咱們只要填寫RTMP服務地址,直接就能夠進行推流啦。
  • PLCameraStreamingKit: 也是一個不錯的 RTMP 直播推流 SDK。

  

PS: 另外其實好多第三方的集成也很好用,可參考git

2、LFLiveKit框架的使用

 1 // 直播會話
 2 - (LFLiveSession*)session {
 3     if (!_session) {
 4         _session = [[LFLiveSession alloc] initWithAudioConfiguration:[LFLiveAudioConfiguration defaultConfiguration] videoConfiguration:[LFLiveVideoConfiguration defaultConfiguration]];
 5         _session.preView = self;
 6         _session.delegate = self;
 7     }
 8     return _session;
 9 }
10 // 開始直播
11 - (void)startLive {    
12     LFLiveStreamInfo *streamInfo = [LFLiveStreamInfo new];
13     streamInfo.url = @"your server rtmp url";
14     [self.session startLive:streamInfo];
15 }
16 // 結束直播
17 - (void)stopLive {
18     [self.session stopLive];
19 }
20 
21 //MARK: - CallBack:
22 - (void)liveSession:(nullable LFLiveSession *)session liveStateDidChange: (LFLiveState)state;
23 - (void)liveSession:(nullable LFLiveSession *)session debugInfo:(nullable LFLiveDebug*)debugInfo;
24 - (void)liveSession:(nullable LFLiveSession*)session errorCode:(LFLiveSocketErrorCode)errorCode;
相關文章
相關標籤/搜索