kingslay / KSPlayer

A video player for iOS、macOS、tvOS、visionOS , based on AVPlayer and FFmpeg, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles.
GNU General Public License v3.0
868 stars 182 forks source link

Cannot run AV1 codecs Video #779

Closed X901 closed 2 months ago

X901 commented 2 months ago

Hi, I want to use your library because it dose support av1 and other format and codecs that AvPlayer can't play I tried your app in AppStore and I add the video via Files the video was working fine !

but when I tried the library it doesn't work !

this is my code and video URL

import SwiftUI
import KSPlayer

struct ContentView: View {

    var body: some View {
        VStack {

           KSVideoPlayerView(url: URL(string: "https://p190.p3.n0.cdn.zight.com/items/rRuDqD4R/09cdf85a-cba0-43ba-a4ae-ac3500744404.mp4?source=viewer&v=534dcdb1caf2b5e3b94fd7baf4e8e63a")!, options: KSOptions())

        }
        .padding()
    }

}

also when I tap "play"button I get these warnings

Screenshot 2024-04-25 at 4 14 47 PM
kingslay commented 2 months ago

这个是因为参数配置有问题。你可以参考下我的demo。 如果您还是有问题的话,我这边可以提供技术支持。有两个收费方式:

  1. 单次技术支持收费50美元。
  2. 持续每个月捐赠30美元以上(这个跟LGPL的捐赠是分开的)
X901 commented 2 months ago

This not make any sense, I ask you something in your library but you don't want to give me answer! why don't you make your library open source if you don't want to help develops using your library? you said there is some configuration, I check the demo I don't find any !

kingslay commented 2 months ago

我的demo是开源的,你是可以查看到我的demo的所有代码和配置。如果我的demo是可以播放av1的话,那就代表是你的代码 有问题。那就需要你对比你的代码和我的demo代码里面的区别,找出差异点。如果你不想付出时间来查看demo的话,想要更快的解决问题。那你就可以付出金钱来请求帮助。

X901 commented 2 months ago

For anyone facing this issue and unable to play some video codecs or video types like "mkv," etc., you just need to add the following in init or onAppear:

init() {
    KSOptions.firstPlayerType = KSMEPlayer.self
    KSOptions.secondPlayerType = KSMEPlayer.self
}

The default value of firstPlayerType is KSAVPlayer.self, which means it depends on AVPlayer. As a result, it cannot play AV1 codecs or any video types that AVPlayer does not support. By changing it to KSMEPlayer.self, it will support every codec and video type that the library supports.

Alternatively, you can use KSAVPlayer.self as the first player type and KSMEPlayer.self as the second player type. This way, it will first attempt to play the video using AVPlayer and, if it can't play it, will switch to MEPlayer.