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, SwiftUI, support subtitles.
https://apps.apple.com/app/tracyplayer/id6450770064
GNU General Public License v3.0
1.02k stars 201 forks source link

Problem with Audio / channels / layout #331

Closed skrew closed 1 year ago

skrew commented 1 year ago

Hi,

Users complaining about the audio support:

I have a 5.1 hardware, the lib always send 5.1 sound, even if i'm watching a simple stereo TV channel
And if i'm watching a 5.1 movie, it play as stereo (2.0) mode

My app have MPVLib too, and with MPV the same user tell it's working fine.

I have watched ao_audiounit.m and it look like they use LPCM mode to handle all situations.

What do you think ?

skrew commented 1 year ago

For the moment, it's ok for me to tell users to modify the audio options from auto to stereo if needed.

BTW users still complaining about the central audio in 5.1 or 7.1 is "muted"

I'm off for a few days now, you can still test with others dev here which have a 5.1 sound system for this problem

kingslay commented 1 year ago

For the moment, it's ok for me to tell users to modify the audio options from auto to stereo if needed.

BTW users still complaining about the central audio in 5.1 or 7.1 is "muted"

I'm off for a few days now, you can still test with others dev here which have a 5.1 sound system for this problem

那个用户如果用系统播放器 播放5.1的视频。那中间的音响会有声音吗? 用mpv播放5.1的效果是怎么样的呢 中间也会没有声音吗

skrew commented 1 year ago

With MPV, it works fine for me, whatever the number of channels of the video, i'm still in stereo mode (which is my sound system) even with "auto" in tvOS sound configuration.

For the user with 5.1 / 7.1 sound system, it works fine with MPV too, and he has just confirmed the central audio is working with MPV

Alanko5 commented 1 year ago

Mpv fix fot tvos 16

https://github.com/mpv-player/mpv/pull/10648

JeremTM93 commented 1 year ago

Hi. I don't understand why this topic is closed. Indeed I always have big sound problems with KS with my two Home cinema systems. The soundtracks in 5.1 and 7.1 do not work correctly unlike MPV and it is very frustrating. When reading these sound tracks, the channels (dialogue) are only played with the subwoofer (lfe), the center speaker remains silent, so it is impossible to listen to a stream correctly 🙁

kingslay commented 1 year ago

@JeremTM93 你手头上是有5.1的设备吗?那麻烦你用ks来播放下5.1的视频,然后发下日志给我。日志可以通过关键字channelLayout过滤出音轨相关的信息。谢谢你。

JeremTM93 commented 1 year ago

Sorry I don't have a Macintosh. we will find another way to debug.

cxfksword commented 1 year ago

@kingslay 我索尼电视是5.1的,播放杜比5.1音轨视频就不能听到对话,只有环境音,日志:

KSPlayer: AudioEnginePlayer.swift:277 channelLayout | audio unit channelLayout tag: 0
KSPlayer: KSPlayerLayer.swift:149 state | playerStateDidChange - readyToPlay
KSPlayer: Resample.swift:285 channelLayout(channelCount:) | KSOptions channelLayout: AudioChannelLayout(mChannelLayoutTag: 0, mChannelBitmap: __C.AudioChannelBitmap(rawValue: 0), mNumberChannelDescriptions: 6, mChannelDescriptions: __C.AudioChannelDescription(mChannelLabel: 1, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)))
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 1
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 0
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 2
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 1
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 4
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 3
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 3
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 2
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 5
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 4
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 6
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 5
KSPlayer: Resample.swift:317 channelLayout(channelCount:) | out channelLayout mask: 63
KSPlayer: Resample.swift:243 init(codecpar:outChannel:outSampleRate:) | out channelLayout: AVChannelLayout(order: __C.AVChannelOrder(rawValue: 1), nb_channels: 6, u: __C.AVChannelLayout.__Unnamed_union_u(), opaque: nil)

AVAudioSession.sharedInstance().maximumOutputNumberOfChannels的值是6,我注释AudioEnginePlayer下面两句代码就会恢复正常,但不知有什么影响:

if AVAudioSession.sharedInstance().outputNumberOfChannels > 2, let audioUnit = engine.outputNode.audioUnit {
            options.channelLayout = AVAudioChannelLayout(layout: audioUnit.channelLayout)
        }
kingslay commented 1 year ago

@cxfksword 注释掉这个代码之后。那播放出来的声音是5.1的吗?

cxfksword commented 1 year ago

@cxfksword 注释掉这个代码之后。那播放出来的声音是5.1的吗?

是降为普通立体声了

kingslay commented 1 year ago

@cxfksword 注释掉这个代码之后。那播放出来的声音是5.1的吗?

是降为普通立体声了

@cxfksword 我改了下 麻烦你在试下声音是否是播放5.1

cxfksword commented 1 year ago

还是一样,CENTER FRONT没声音,我强制改了一下layout,测试结果是这样:

不强制改layout:CENTER FRONT没声,其他声道正常 kAudioChannelLayoutTag_AAC_5_0: LOW_FREQUENCY没声,其他声道正常 kAudioChannelLayoutTag_AAC_5_1: SIDE RIGHT没声,其他声道正常

我看了kAudioChannelLayoutTag_UseChannelDescriptions和kAudioChannelLayoutTag_AAC_5_1的mask是一样的,但播放出来的结果却不同。。。

kingslay commented 1 year ago

我怀疑是音轨的顺序有问题。我这边5.1的顺序是 KSPlayer: Resample.swift:314 channelLayout(channelCount:) | KSOptions channelLayout label: 3 KSPlayer: Resample.swift:316 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 2 KSPlayer: Resample.swift:314 channelLayout(channelCount:) | KSOptions channelLayout label: 1 KSPlayer: Resample.swift:316 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 0 KSPlayer: Resample.swift:314 channelLayout(channelCount:) | KSOptions channelLayout label: 2 KSPlayer: Resample.swift:316 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 1 KSPlayer: Resample.swift:314 channelLayout(channelCount:) | KSOptions channelLayout label: 5 KSPlayer: Resample.swift:316 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 9 KSPlayer: Resample.swift:314 channelLayout(channelCount:) | KSOptions channelLayout label: 6 KSPlayer: Resample.swift:316 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 10 KSPlayer: Resample.swift:314 channelLayout(channelCount:) | KSOptions channelLayout label: 4 KSPlayer: Resample.swift:316 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 3 KSPlayer: Resample.swift:324 channelLayout(channelCount:) | out channelLayout mask: 1551 nb_channels: 6

你的音响输出的顺序是什么呢?

kingslay commented 1 year ago

你的音响是不是设置成kAudioChannelLayoutTag_DVD_6 呢 ///< L R LFE Ls Rs public var kAudioChannelLayoutTag_DVD_6: AudioChannelLayoutTag { get }

cxfksword commented 1 year ago

输出:

KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 1
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 0
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 2
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 1
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 4
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 3
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 3
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 2
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 5
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 9
KSPlayer: Resample.swift:307 channelLayout(channelCount:) | KSOptions channelLayout label: 6
KSPlayer: Resample.swift:309 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 10
KSPlayer: Resample.swift:317 channelLayout(channelCount:) | out channelLayout mask: 1551
kingslay commented 1 year ago

你的这个顺序怪怪的,是音响默认的吗?相当于是 L R Lfe C Ls Rs。 苹果系统里面是没有这个布局的音响的

cxfksword commented 1 year ago

你的这个顺序怪怪的,是音响默认的吗?相当于是 L R Lfe C Ls Rs。 苹果系统里面是没有这个布局的音响的

是索尼电视默认的,其实我电视只有两个扬声器,5.1应该是模拟的

cxfksword commented 1 year ago

我试了使用infuse和其他mpv播放器的app都是降为立体声播放的,就ksplayer切换为5.1了

kingslay commented 1 year ago

我试了使用infuse和其他mpv播放器的app都是降为立体声播放的,就ksplayer切换为5.1了

apple tv上的设置的 音频格式你是不是设置成自动呢?还是设置为杜比5.1呢?

kingslay commented 1 year ago

你的这个顺序怪怪的,是音响默认的吗?相当于是 L R Lfe C Ls Rs。 苹果系统里面是没有这个布局的音响的

是索尼电视默认的,其实我电视只有两个扬声器,5.1应该是模拟的 这个是怎么样模拟的呢。是索尼电视支持的吗。还是在Apple tv上设置的

kingslay commented 1 year ago

@cxfksword 需要找下原因为什么 AVAudioSession.sharedInstance().maximumOutputNumberOfChannels 的值会大于2。你的设备这个值是不是8呢?

cxfksword commented 1 year ago

我试了使用infuse和其他mpv播放器的app都是降为立体声播放的,就ksplayer切换为5.1了

apple tv上的设置的 音频格式你是不是设置成自动呢?还是设置为杜比5.1呢?

只有自动,没见显示杜比5.1

cxfksword commented 1 year ago

你的这个顺序怪怪的,是音响默认的吗?相当于是 L R Lfe C Ls Rs。 苹果系统里面是没有这个布局的音响的

是索尼电视默认的,其实我电视只有两个扬声器,5.1应该是模拟的 这个是怎么样模拟的呢。是索尼电视支持的吗。还是在Apple tv上设置的

是索尼电视自带的,虚拟5.1

cxfksword commented 1 year ago

@cxfksword 需要找下原因为什么 AVAudioSession.sharedInstance().maximumOutputNumberOfChannels 的值会大于2。你的设备这个值是不是8呢?

输出是6

UnknownCoder807 commented 1 year ago

With thanks to one of my beta testers, I have managed to get my apple tv and soundbar setup correctly so I can now hear full 5.1 and 7.1 when available.

I can confirm that on my setup there is NO centre speaker sound when playing a test 5.1 or 7.1 surround sound test video. This is using your untouched swiftui player view in a demo app.

If I can provide any debugging logs I will gladly do so, as I have access to xcode debugging.

kingslay commented 1 year ago

@UnknownCoder807 用昨天最新的代码。 centre speaker 还是没有声音吗?

UnknownCoder807 commented 1 year ago

@UnknownCoder807 用昨天最新的代码。 centre speaker 还是没有声音吗?

Using the latest code, I get no sound on centre.

KSPlayer: AudioEnginePlayer.swift:277 channelLayout | audio unit channelLayout tag: 0
KSPlayer: KSPlayerLayer.swift:149 state | playerStateDidChange - readyToPlay
KSPlayer: Resample.swift:285 channelLayout(channelCount:) | KSOptions channelLayout: AudioChannelLayout(mChannelLayoutTag: 0, mChannelBitmap: __C.AudioChannelBitmap(rawValue: 0), mNumberChannelDescriptions: 6, mChannelDescriptions: __C.AudioChannelDescription(mChannelLabel: 1, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)))
KSPlayer: Resample.swift:308 channelLayout(channelCount:) | KSOptions channelLayout label: 1
KSPlayer: Resample.swift:310 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 0
KSPlayer: Resample.swift:308 channelLayout(channelCount:) | KSOptions channelLayout label: 2
KSPlayer: Resample.swift:310 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 1
KSPlayer: Resample.swift:308 channelLayout(channelCount:) | KSOptions channelLayout label: 4
KSPlayer: Resample.swift:310 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 3
KSPlayer: Resample.swift:308 channelLayout(channelCount:) | KSOptions channelLayout label: 3
KSPlayer: Resample.swift:310 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 2
KSPlayer: Resample.swift:308 channelLayout(channelCount:) | KSOptions channelLayout label: 5
KSPlayer: Resample.swift:310 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 9
KSPlayer: Resample.swift:308 channelLayout(channelCount:) | KSOptions channelLayout label: 6
KSPlayer: Resample.swift:310 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 10
KSPlayer: Resample.swift:318 channelLayout(channelCount:) | out channelLayout mask: 1551 nb_channels: 6
KSPlayer: Resample.swift:243 init(audioDescriptor:outChannel:outSampleRate:) | out channelLayout: AVChannelLayout(order: __C.AVChannelOrder(rawValue: 1), nb_channels: 6, u: __C.AVChannelLayout.__Unnamed_union_u(), opaque: nil)
kingslay commented 1 year ago

@UnknownCoder807 你用的音响是模拟的5.1,还是真正的5.1呢?

UnknownCoder807 commented 1 year ago

@UnknownCoder807 你用的音响是模拟的5.1,还是真正的5.1呢?

I use the following

https://www.lg.com/ca_en/sound-bars/lg-SN9YG With these added https://www.lg.com/us/sound-bars/lg-SPK8-S-wireless-surround-kit

via HDMI.

I used these videos as a test

https://thedigitaltheater.com/tools/

IMG_7419

kingslay commented 1 year ago

@UnknownCoder807 你试着把 options.channelLayout = AVAudioChannelLayout(layout: audioUnit.channelLayout) 改成 options.channelLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_AAC_5_1)! 看下行不行

UnknownCoder807 commented 1 year ago

options.channelLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_AAC_5_1

There is sound on centre speaker now.

kingslay commented 1 year ago

@UnknownCoder807 播放5.1和7.1 都不会有问题了吗

UnknownCoder807 commented 1 year ago

I have no sound from the rear speakers, but this might be an issue with my setup. I will get back to you later about it once I figure it out.

kingslay commented 1 year ago

@UnknownCoder807 我对代码增加了一些日志。也稍微改了下代码。麻烦你在进行测试下,会不会有 centre speaker没有声音的情况。还有针对你的 rear speakers没有声音的情况你可以用mpv试下,看会不会也是没有声音,如果也是没有声音的话,那就是你的音响配置的问题,如果mpv有声音的话,那估计是我的代码有问题。我在想办法找下是那个地方导致的。

UnknownCoder807 commented 1 year ago

I now have no sound in the centre, but my rears work ok. I don't know how to test with MPV on apple TV as I don't know of any code for swift for it.

KSPlayer: AVFoundationExtension.swift:73 channelLayout | audio unit channelLayout tag: 0
KSPlayer: AVFoundationExtension.swift:75 channelLayout | audio unit channelLayout channelDescriptions: [__C.AudioChannelDescription(mChannelLabel: 1, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 2, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 4, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 3, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 5, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 6, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0))]
KSPlayer: AudioEnginePlayer.swift:153 prepare(options:) | outputFormat channelLayout tag: 0
KSPlayer: AudioEnginePlayer.swift:154 prepare(options:) | outputFormat channelLayout channelDescriptions: [__C.AudioChannelDescription(mChannelLabel: 1, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 2, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 4, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 3, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 5, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 6, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0))]
KSPlayer: AVFoundationExtension.swift:134 channelLayout(channelCount:) | KSOptions channelLayout: AudioChannelLayout(mChannelLayoutTag: 0, mChannelBitmap: __C.AudioChannelBitmap(rawValue: 0), mNumberChannelDescriptions: 6, mChannelDescriptions: __C.AudioChannelDescription(mChannelLabel: 1, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)))
KSPlayer: AVFoundationExtension.swift:153 channelLayout(channelCount:) | KSOptions channelLayout label: 1
KSPlayer: AVFoundationExtension.swift:155 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 0
KSPlayer: AVFoundationExtension.swift:153 channelLayout(channelCount:) | KSOptions channelLayout label: 2
KSPlayer: AVFoundationExtension.swift:155 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 1
KSPlayer: AVFoundationExtension.swift:153 channelLayout(channelCount:) | KSOptions channelLayout label: 4
KSPlayer: AVFoundationExtension.swift:155 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 3
KSPlayer: AVFoundationExtension.swift:153 channelLayout(channelCount:) | KSOptions channelLayout label: 3
KSPlayer: AVFoundationExtension.swift:155 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 2
KSPlayer: AVFoundationExtension.swift:153 channelLayout(channelCount:) | KSOptions channelLayout label: 5
KSPlayer: AVFoundationExtension.swift:155 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 9
KSPlayer: AVFoundationExtension.swift:153 channelLayout(channelCount:) | KSOptions channelLayout label: 6
KSPlayer: AVFoundationExtension.swift:155 channelLayout(channelCount:) | KSOptions channelLayout avChannel: 10
KSPlayer: AVFoundationExtension.swift:163 channelLayout(channelCount:) | out channelLayout mask: 1551 nb_channels: 6
KSPlayer: Resample.swift:190 init(audioDescriptor:outChannel:outSampleRate:) | out channelLayout: AVChannelLayout(order: __C.AVChannelOrder(rawValue: 1), nb_channels: 6, u: __C.AVChannelLayout.__Unnamed_union_u(), opaque: nil)
kingslay commented 1 year ago

@UnknownCoder807 你可以用其他软件试下。例如infuse或vlc之类的

kingslay commented 1 year ago

@UnknownCoder807 你可以试着把 options.channelLayout = AVAudioChannelLayout(layout: audioUnit.channelLayout) 改成 options.channelLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_Logic_5_1_A)! 看下行不行

UnknownCoder807 commented 1 year ago

@UnknownCoder807 你可以用其他软件试下。例如infuse或vlc之类的

I used Plex on my Apple TV and all speakers work with the test video. I believe plex uses MPV?

UnknownCoder807 commented 1 year ago

options.channelLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_Logic_5_1_A)!

No centre but rears work.

kingslay commented 1 year ago

@UnknownCoder807 我提交代码了。麻烦你在试着把 options.channelLayout = AVAudioChannelLayout(layout: audioUnit.channelLayout) 改成 options.channelLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_Logic_5_1_A)! 看下行不行

UnknownCoder807 commented 1 year ago

@UnknownCoder807 我提交代码了。麻烦你在试着把 options.channelLayout = AVAudioChannelLayout(layout: audioUnit.channelLayout) 改成 options.channelLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_Logic_5_1_A)! 看下行不行

Screenshot 2023-01-09 at 14 23 24
kingslay commented 1 year ago

@UnknownCoder807 我提交修复代码了。麻烦你在试下

UnknownCoder807 commented 1 year ago

@UnknownCoder807 我提交修复代码了。麻烦你在试下

Centre works and so do rears.

KSPlayer: AudioEnginePlayer.swift:153 prepare(options:) | outputFormat channelLayout tag: 0
KSPlayer: AudioEnginePlayer.swift:154 prepare(options:) | outputFormat channelLayout channelDescriptions: [__C.AudioChannelDescription(mChannelLabel: 1, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 2, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 4, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 3, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 5, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 6, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0))]
KSPlayer: AVFoundationExtension.swift:134 channelLayout(channelCount:) | KSOptions channelLayout: AudioChannelLayout(mChannelLayoutTag: 7929862, mChannelBitmap: __C.AudioChannelBitmap(rawValue: 0), mNumberChannelDescriptions: 0, mChannelDescriptions: __C.AudioChannelDescription(mChannelLabel: 0, mChannelFlags: __C.AudioChannelFlags(rawValue: 1), mCoordinates: (0.0, 6.1440533e-33, 1e-45)))
KSPlayer: KSPlayerLayer.swift:149 state | playerStateDidChange - readyToPlay
KSPlayer: Resample.swift:190 init(audioDescriptor:outChannel:outSampleRate:) | out channelLayout: AVChannelLayout(order: __C.AVChannelOrder(rawValue: 1), nb_channels: 6, u: __C.AVChannelLayout.__Unnamed_union_u(), opaque: nil)
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | Using fltp internally between filters

KSPlayer: MEPlayerItem.swift:127 init(url:options:) | Matrix coefficients:

KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FL: 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FL:1.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FC:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | LFE:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | 

KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FR: 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FR:1.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FC:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | LFE:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | 

KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FC: 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FC:1.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | LFE:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | 

KSPlayer: MEPlayerItem.swift:127 init(url:options:) | LFE: 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FC:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | LFE:1.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | 

KSPlayer: MEPlayerItem.swift:127 init(url:options:) | BL: 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FC:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | LFE:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SL:1.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | 

KSPlayer: MEPlayerItem.swift:127 init(url:options:) | BR: 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FR:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | FC:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | LFE:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SL:0.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | SR:1.000000 
KSPlayer: MEPlayerItem.swift:127 init(url:options:) | 
UnknownCoder807 commented 1 year ago

7.1 doesn't work though. no centre and rears

kingslay commented 1 year ago

@UnknownCoder807 7.1的日志发给我下,

UnknownCoder807 commented 1 year ago
KSPlayer: AudioEnginePlayer.swift:153 prepare(options:) | outputFormat channelLayout tag: 0
KSPlayer: AudioEnginePlayer.swift:154 prepare(options:) | outputFormat channelLayout channelDescriptions: [__C.AudioChannelDescription(mChannelLabel: 1, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 2, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 4, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 3, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 5, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 6, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 33, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 34, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0))]
KSPlayer: KSPlayerLayer.swift:149 state | playerStateDidChange - readyToPlay
KSPlayer: AVFoundationExtension.swift:134 channelLayout(channelCount:) | KSOptions channelLayout: AudioChannelLayout(mChannelLayoutTag: 7929862, mChannelBitmap: __C.AudioChannelBitmap(rawValue: 0), mNumberChannelDescriptions: 0, mChannelDescriptions: __C.AudioChannelDescription(mChannelLabel: 0, mChannelFlags: __C.AudioChannelFlags(rawValue: 2211160496), mCoordinates: (3e-45, 0.0, 0.0)))
KSPlayer: Resample.swift:190 init(audioDescriptor:outChannel:outSampleRate:) | out channelLayout: AVChannelLayout(order: __C.AVChannelOrder(rawValue: 1), nb_channels: 8, u: __C.AVChannelLayout.__Unnamed_union_u(), opaque: nil)
kingslay commented 1 year ago

@UnknownCoder807 如果是7.1的话,麻烦你在试着把 options.channelLayout = AVAudioChannelLayout(layout: audioUnit.channelLayout) 改成 options.channelLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_Logic_7_1_A)! 看下行不行

UnknownCoder807 commented 1 year ago

@UnknownCoder807 如果是7.1的话,麻烦你在试着把 options.channelLayout = AVAudioChannelLayout(layout: audioUnit.channelLayout) 改成 options.channelLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_Logic_7_1_A)! 看下行不行

Sorry my mistake, it should have been obvious to change 5_1 to 7_1

Anyway, centre works and rears work.

KSPlayer: AudioEnginePlayer.swift:155 prepare(options:) | outputFormat channelLayout tag: 0
KSPlayer: AudioEnginePlayer.swift:156 prepare(options:) | outputFormat channelLayout channelDescriptions: [__C.AudioChannelDescription(mChannelLabel: 1, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 2, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 4, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 3, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 5, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 6, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 33, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 34, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0))]
KSPlayer: AVFoundationExtension.swift:134 channelLayout(channelCount:) | KSOptions channelLayout: AudioChannelLayout(mChannelLayoutTag: 8388616, mChannelBitmap: __C.AudioChannelBitmap(rawValue: 0), mNumberChannelDescriptions: 0, mChannelDescriptions: __C.AudioChannelDescription(mChannelLabel: 0, mChannelFlags: __C.AudioChannelFlags(rawValue: 1), mCoordinates: (0.0, 6.3391907e-27, 1e-45)))
KSPlayer: KSPlayerLayer.swift:149 state | playerStateDidChange - readyToPlay
KSPlayer: Resample.swift:190 init(audioDescriptor:outChannel:outSampleRate:) | out channelLayout: AVChannelLayout(order: __C.AVChannelOrder(rawValue: 1), nb_channels: 8, u: __C.AVChannelLayout.__Unnamed_union_u(), opaque: nil)
UnknownCoder807 commented 1 year ago

What happens if any user has any one of the following Dolby Atmos system?

@kingslay can ksplayer define all those atmos sound output? Or can you implement it? also, with logic_7_1_A, 5.1 videos do not output centre sound.

IMG_7449

JeremTM93 commented 1 year ago

@UnknownCoder807 如果是7.1的话,麻烦你在试着把 options.channelLayout = AVAudioChannelLayout(layout: audioUnit.channelLayout) 改成 options.channelLayout = AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_Logic_7_1_A)! 看下行不行

Sorry my mistake, it should have been obvious to change 5_1 to 7_1

Anyway, centre works and rears work.

KSPlayer: AudioEnginePlayer.swift:155 prepare(options:) | outputFormat channelLayout tag: 0
KSPlayer: AudioEnginePlayer.swift:156 prepare(options:) | outputFormat channelLayout channelDescriptions: [__C.AudioChannelDescription(mChannelLabel: 1, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 2, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 4, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 3, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 5, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 6, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 33, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0)), __C.AudioChannelDescription(mChannelLabel: 34, mChannelFlags: __C.AudioChannelFlags(rawValue: 0), mCoordinates: (0.0, 0.0, 0.0))]
KSPlayer: AVFoundationExtension.swift:134 channelLayout(channelCount:) | KSOptions channelLayout: AudioChannelLayout(mChannelLayoutTag: 8388616, mChannelBitmap: __C.AudioChannelBitmap(rawValue: 0), mNumberChannelDescriptions: 0, mChannelDescriptions: __C.AudioChannelDescription(mChannelLabel: 0, mChannelFlags: __C.AudioChannelFlags(rawValue: 1), mCoordinates: (0.0, 6.3391907e-27, 1e-45)))
KSPlayer: KSPlayerLayer.swift:149 state | playerStateDidChange - readyToPlay
KSPlayer: Resample.swift:190 init(audioDescriptor:outChannel:outSampleRate:) | out channelLayout: AVChannelLayout(order: __C.AVChannelOrder(rawValue: 1), nb_channels: 8, u: __C.AVChannelLayout.__Unnamed_union_u(), opaque: nil)

Do you have Dolby Atmos displayed on compatible content (Atmos dolby digital+), as with infuse?