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.

暂无版本1,692star +2 / 7 天333fork同步于 2026-11-10 17:49 UTC

怎么上手

由 README 提炼,执行前请确认
dependencies: [
    .package(url: "https://github.com/kingslay/KSPlayer.git", .branch("main"))
]
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求,仅列出系统要求:iOS 13+、macCatalyst 14+、macOS 10.15+、tvOS 13+、xrOS 1+。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

苹果全平台视频播放框架,基于 AVPlayer 与 FFmpeg,支持 HDR 与杜比视界

基于 AVPlayer 和 FFmpeg 的苹果全平台视频播放器,支持 HLG、HDR10、杜比视界与杜比全景声,以及图文混合字幕。

核心能力

  • 基于 AVPlayer 与 FFmpeg 双引擎,KSMEPlayer 支持全部解封装与解码格式
  • 支持 HLG、HDR10、HDR10+、Dolby Vision 与 Dolby Atmos
  • 支持文本字幕、图片字幕(如 SUP)与 ASS 特效渲染
  • 提供 Swift Concurrency 与硬件加速、硬件去隔行
  • 支持画中画、360° 全景、多码率自适应与低延迟直播

容易踩的坑

默认采用 GPL 许可证,商业闭源项目需另行获取 LGPL 或商业授权;部分功能(如视频超分、原生杜比视界动态元数据、蓝光播放)属于付费特性,开源版不含;GPL 版 KSPlayer 模块仅提供 macOS、iSimulator、tvOS 的动态二进制,其他平台需用 LGPL 源码版。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Build Status Platform License

    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.

    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.

    ModuleGPL VersionLGPL Version
    KSPlayerDynamic Binary, only macOS、iSimulator、tvOSSource code, all Apple platforms
    KSPlayerUISource code, all Apple platformsSource code, all Apple platforms
    MPVPlayerSource code, all Apple platformsSource 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.

    App Store LinkLogo
    APTV
    homeTV IPTV Player
    Interlace Player
    IPTV +
    LillyPlayer Video Player
    Mert Stream TV
    MyKroko
    SeeTV
    SenPlayer
    Smart IPTV
    Snappier IPTV
    StreamX
    SWIPTV - IPTV Smart Player
    UHF - Love your IPTV
    Zen IPTV

    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

    gif

    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.

    NameApp nameApp Logo
    UnknownCoder807Snappier
    skrew
    Kimentanm
    nakiostudioUHF
    CodingByJerez
    andrefmsilva
    romaingyhZen IPTV
    archrainey
    nihalahmed
    johnil
    MeloDreek
    nsplay1990
    AppleChillVibez
    bmob222
    pateltejas
    ewanl2001
    JulienDev
    Sheinices
    Etheirystech
    loicleser

    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

    1