默认采用 GPL 许可证,商业闭源项目需另行获取 LGPL 或商业授权;部分功能(如视频超分、原生杜比视界动态元数据、蓝光播放)属于付费特性,开源版不含;GPL 版 KSPlayer 模块仅提供 macOS、iSimulator、tvOS 的动态二进制,其他平台需用 LGPL 源码版。
KSPlayer
kingslayGPL-3.0活跃维护基于 AVPlayer 和 FFmpeg 的苹果全平台视频播放器,支持 HLG、HDR10、杜比视界与杜比全景声,以及图文混合字幕。
A video player for iOS、macOS、tvOS、visionOS , based on AVPlayer and FFmpeg, support HLG、HDR10、 HDR10+、Dolby Vision、Dolby Atmos、Text/Image subtitle.
dependencies: [
.package(url: "https://github.com/kingslay/KSPlayer.git", .branch("main"))
]README 未说明具体显存或 GPU 型号要求,仅列出系统要求:iOS 13+、macCatalyst 14+、macOS 10.15+、tvOS 13+、xrOS 1+。
苹果全平台视频播放框架,基于 AVPlayer 与 FFmpeg,支持 HDR 与杜比视界
基于 AVPlayer 和 FFmpeg 的苹果全平台视频播放器,支持 HLG、HDR10、杜比视界与杜比全景声,以及图文混合字幕。
核心能力
- 基于 AVPlayer 与 FFmpeg 双引擎,KSMEPlayer 支持全部解封装与解码格式
- 支持 HLG、HDR10、HDR10+、Dolby Vision 与 Dolby Atmos
- 支持文本字幕、图片字幕(如 SUP)与 ASS 特效渲染
- 提供 Swift Concurrency 与硬件加速、硬件去隔行
- 支持画中画、360° 全景、多码率自适应与低延迟直播
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
KSPlayer
KSPlayer is a powerful media play framework for iOS, macCatalyst, macOS, tvOS, xrOS, visionOS. based on AVPlayer and FFmpeg, support HLG、HDR10、 HDR10+、Dolby Vision、Dolby Atmos、Text/Image subtitle.
English | 简体中文
Communication
If you have a commercial project that requires a custom player, or would like to receive a paid consultation, please email me.
- Email : [email protected]
License
KSPlayer defaults to the GPL license (requires open-sourcing your own project code), and we hope everyone will consciously respect the licensing agreement of the KSPlayer project. Additionally, There is a paid version available under the LGPL license. You can check this post for details on the licensing options or send me an email. If I don't reply to your email, feel free to @mention me in this post.
If due to commercial reasons, you prefer not to adhere to the GPL license or the LGPL license, you can contact us. Through our authorization, you can obtain a more flexible licensing agreement.
Features
Differences between GPL version and LGPL version.
| Module | GPL Version | LGPL Version |
|---|---|---|
| KSPlayer | Dynamic Binary, only macOS、iSimulator、tvOS | Source code, all Apple platforms |
| KSPlayerUI | Source code, all Apple platforms | Source code, all Apple platforms |
| MPVPlayer | Source code, all Apple platforms | Source code, all Apple platforms |
One-time Paid Features
- Video upscaling
- ProgressBar Preview
- AVPlayer supports MKV
- Height Channel Layout
- Native Dolby Atmos (E-AC-3)
- Precache data to Hard Drive
- Video output to another screen
- Video switching with zero delay
- Audio Passthrough Output by Wi-Fi
- Live streaming supports rewind viewing
- Offline AI real-time subtitle generation
- Native Dolby Vision dynamic metadata (P5、P7、P8、P10)
- Simultaneous playback of separate audio and video URLs
- Blu-ray disc (ISO, BDMV, DVD) playback on all Apple platforms
- Play videos in a small window in the App (resumable, supports iOS and tvOS)
To experience the paid features, you can download the app from the App Store. App Store Link Test Flight Link
Free Features
- Dolby AC-4
- Swift Concurrency
- Hardware De-interlace
- AV1 hardware decoding
- Word-by-word subtitles
- HDR10+ dynamic metadata
- Text subtitle translation
- Use System Caption Appearance
- Record video clips at any time
- Smoothly Play 8K or 120 FPS Video
- Display Subtitles with HDR Effects
- Video download and format conversion
- External image subtitles, such as SUP
- Main subtitles and Secondary subtitles
- Offline AI real-time subtitle translation
- Adjust Saturation, Brightness, and Contrast
- Picture in Picture supports subtitle display
- Annex-B async hardware decoding (Live Stream)
- Use the fonts in the video to render subtitles
- Use memory cache for fast seek in short time range
- KSMEPlayer supports all demuxing and decoding formats
- Full display of ASS subtitle effects (rendered as images using libass)
- Record video
- 4K / HDR / HDR10
- 360° panorama video
- Picture in Picture
- Hardware accelerator
- Automatic de-interlace detection
- Multichannel Audio / Spatial Audio
- Custom URL protocols such as NFS / SMB
- Text subtitles / Image subtitles / Closed Captions
- Seamless loop playback within a specific range
- Search online subtitles (Shooter / ASSRT / OpenSubtitles)
- Low-latency 4K live video streaming (less than 200 ms on LAN)
- Automatically switch to multi-bitrate streams based on network conditions
Requirements
- iOS 13+, macCatalyst 14+, macOS 10.15+, tvOS 13+, xrOS 1+
List of Apps Licensed to Use this SDK
This table does not list all licensed apps. If you would like to have your app listed above, please send me an email.
Demo
- Open Demo/Demo.xcworkspace with Xcode.
Quick Start
Swift Package Manager
dependencies: [
.package(url: "https://github.com/kingslay/KSPlayer.git", .branch("main"))
]
Usage
Initialization
import KSPlayer
import KSPlayerUI
KSOptions.secondPlayerType = KSMEPlayer.self
playerView = IOSVideoPlayerView()
view.addSubview(playerView)
playerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
playerView.topAnchor.constraint(equalTo: view.readableContentGuide.topAnchor),
playerView.leftAnchor.constraint(equalTo: view.leftAnchor),
playerView.rightAnchor.constraint(equalTo: view.rightAnchor),
playerView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
playerView.backBlock = { [unowned self] in
if UIApplication.shared.statusBarOrientation.isLandscape {
self.playerView.updateUI(isLandscape: false)
} else {
self.navigationController?.popViewController(animated: true)
}
}
Setting up a regular video
import KSPlayer
import KSPlayerUI
playerView.set(url:URL(string: "http://baobab.wdjcdn.com/14525705791193.mp4")!)
playerView.set(resource: KSPlayerResource(url: url, name: name!, cover: URL(string: "http://img.wdjimg.com/image/video/447f973848167ee5e44b67c8d4df9839_0_0.jpeg"), subtitleURL: URL(string: "http://example.ksplay.subtitle")))
Multi-definition, with cover video
import KSPlayer
import KSPlayerUI
let res0 = KSPlayerResourceDefinition(url: URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!,
definition: "高清")
let res1 = KSPlayerResourceDefinition(url: URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!,
definition: "标清")
let asset = KSPlayerResource(name: "Big Buck Bunny",
definitions: [res0, res1],
cover: URL(string: "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Big_buck_bunny_poster_big.jpg/848px-Big_buck_bunny_poster_big.jpg"))
playerView.set(resource: asset)
Setting up an HTTP header
import KSPlayer
import KSPlayerUI
let options = KSOptions()
options.appendHeader(["Referer":"https:www.xxx.com"])
let definition = KSPlayerResourceDefinition(url: URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!,
definition: "高清",
options: options)
let asset = KSPlayerResource(name: "Video Name",
definitions: [definition])
playerView.set(resource: asset)
Listening status change
import KSPlayer
import KSPlayerUI
// Listen to play time change
playerView.playTimeDidChange = { (currentTime: TimeInterval, totalTime: TimeInterval) in
print("playTimeDidChange currentTime: \(currentTime) totalTime: \(totalTime)")
}
// Delegates
public protocol PlayerControllerDelegate: class {
func playerController(state: KSPlayerState)
func playerController(currentTime: TimeInterval, totalTime: TimeInterval)
func playerController(finish error: Error?)
func playerController(maskShow: Bool)
func playerController(action: PlayerButtonType)
// `bufferedCount: 0` indicates first time loading
func playerController(bufferedCount: Int, consumeTime: TimeInterval)
}
Advanced Usage
Inherits PlayerView's custom play logic and UI.
import KSPlayer
import KSPlayerUI
class CustomVideoPlayerView: IOSVideoPlayerView {
override func updateUI(isLandscape: Bool) {
super.updateUI(isLandscape: isLandscape)
toolBar.playbackRateButton.isHidden = true
}
override func onButtonPressed(type: PlayerButtonType, button: UIButton) {
if type == .landscape {
// Your own button press behaviour here
} else {
super.onButtonPressed(type: type, button: button)
}
}
}
Selecting Tracks
import KSPlayer
import KSPlayerUI
override open func player(layer: KSPlayerLayer, state: KSPlayerState) {
super.player(layer: layer, state: state)
if state == .readyToPlay, let player = layer.player {
let tracks = player.tracks(mediaType: .audio)
let track = tracks[1]
/// the name of the track
let name = track.name
/// the language of the track
let language = track.language
/// selecting the one
player.select(track: track)
}
}
Effect

Developments and Tests
Any contributing and pull requests are warmly welcome. However, before you plan to implement some features or try to fix an uncertain issue, it is recommended to open a discussion first. It would be appreciated if your pull requests could build and with all tests green. :)
Backers & Sponsors
Open-source projects cannot live long without your help. If you find KSPlayer to be useful, please consider supporting this project by becoming a sponsor.
Become a sponsor through GitHub Sponsors. :heart:
Your user icon or company logo shows up this with a link to your home page.
Thanks to nightfall708 for sponsoring a mac mini
Thanks to cdguy UnknownCoder807 skrew and LillyPlayer community for sponsoring a LG S95QR Sound Bar
Thanks to skrew and LillyPlayer community for sponsoring a 2022 Apple TV 4K
Thanks to bgoncal for sponsoring a HomePod mini
