需在 iOS App 中拉取 RTMP 流並播放,GitHub 搜索多為原理說明,缺乏可用 Demo。
| 庫 | 語言 | 特點 | 接入難度 |
|---|---|---|---|
| LFLiveKit | ObjC/Swift | 推流+拉流、RTMP/FLV、美顏濾鏡、文檔全 | 低 |
| ijkplayer (k0shk0sh/ijkplayer) | C/ObjC | Bilibili 維護、FFmpeg 核心、支持 RTMP/HLS/FLV/MP4、硬解 | 中 |
| PLPlayerKit (七牛) | ObjC | 商業級、低延遲、弱網抗性、收費 | 低 |
| VLCKit (MobileVLCKit) | ObjC | VLC 內核、格式全、體積大、GPL 授權 | 中 |
| HaishinKit.swift | Swift | 純 Swift、RTMP/HTTP-FLV/WebRTC、活躍維護 | 低 |
LFLiveKit (拉流):
// Podfile
pod 'LFLiveKit'
// ViewController
import LFLiveKit
let session = LFLiveSession()
session.delegate = self
session.preView = self.view
session.running = true
let stream = LFLiveStreamInfo()
stream.url = "rtmp://your-server/live/streamKey" // 拉流地址
session.startLive(stream) // 實為開始拉流播放
ijkplayer:
let options = IJKFFOptions.byDefault()
let player = IJKFFMoviePlayerController(contentURLString: "rtmp://...", with: options)
player.view.frame = view.bounds
view.addSubview(player.view)
player.prepareToPlay()
player.play()
AVPlayer 完美支持,零三方依賴、體積小、硬解高效。