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 200 forks source link

“AudioUnit” framework and incorrect spatial audio info on TVOS #609

Closed cdguy closed 12 months ago

cdguy commented 12 months ago

AudioUnit framework on tvos has an issue

IMG_7297

the stream I play on Tvos is stereo. However when I use my airpods, TracyPlayer says that the audio is “multi channel audio”. Also I can’t use the “make the stereo sound spatial audio” feature

however when I play the same stream on ios, the sound label is “stereo” and if I want, I can make the stereo sound spatial audio

IMG_7296

cdguy commented 12 months ago

I don’t know if it is related but I found a bug that happens no matter which Audio Framework I use.

here is how you can replicate:

1- it doesn’t matter if you have a home theatre or not, when you navigate through the appleTV menus, the sound output is 2.0

2- open a content that has 5.1 audio properties via an application (Netflix, apple music [music with spatial audio], etc.) the sound output is 5.1 (or more).

3- quit/close the application and you will see that the sound output is back to 2.0

the first 3 amendments mentioned above is the correct behaviour.

However when I use tracyplayer here is the bug:

1- open a content that has 5.1 (or more) audio properties. You will see that the sound output goes from stereo to 5.1 (or more)

2- stop/quit the stream; you will see that the sound output of the AppleTV is still 5.1 (or more)

3- open a stereo content. You will see that the audio channel used is still 5.1. However this should be 2.1. And even if you quit TracyPlayer you will see that the sound output is 5.1 (however it should be changed to stereo)

4- the only way to stop this issue, is to turn off and reopen the AppleTV

JeremTM93 commented 12 months ago

I confirm and I had already noticed this problem before the "AudioUnit" option.

When I open a multichannel feed everything is fine :

1000006880.jpg

Then, I close the multichannel stream, I open a 2.0 stereo stream, the player remains stuck in multichannel :

1000006881.jpg

We need to restart the AppleTV for normal operation on a 2.0 stereo stream :

1000006882.jpg

JeremTM93 commented 12 months ago

Can you please update the TracyPlayer demo app ? @kingslay

kingslay commented 12 months ago

可以的,还有一个小问题。我正在改。改好了。就一起更新下

JeremTM93 commented 12 months ago

可以的,还有一个小问题。我正在改。改好了。就一起更新下

Is the latest version of Tracy (36) supposed to fix the stuck multichannel sound issue ?

kingslay commented 12 months ago

是的,你试下

JeremTM93 commented 12 months ago

是的,你试下

No same problem 😕

cdguy commented 12 months ago

https://github.com/kingslay/KSPlayer/commit/52da78912bae8e8af12951d692c9e295edf4726a

This comit has completely broken Spatial Audio for « AudioUnit » framework. Before the commit, at least, I could get spatial audio on ios.

Besides, can you fix the playback speed feature for “AudioUnit” framework?

I guess this thread should be reopened

thank you @kingslay

kingslay commented 12 months ago

@cdguy 你可以试着 audioFilters = ["atempo=2.0"] 。看下这个倍数播放的效果。AudioUnit是无法控制倍数播放的,所以只能试着用filter来实现下。

cdguy commented 12 months ago

@cdguy 你可以试着 audioFilters = ["atempo=2.0"] 。看下这个倍数播放的效果。AudioUnit是无法控制倍数播放的,所以只能试着用filter来实现下。

you can use this documentation:

https://www.1em0n.com/blog/2020/2020-02-28.html

under 调整播放速率:

同时调整视频和音频 ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mkv

and check also this: https://stackoverflow.com/questions/38218956/why-must-ffmpegs-af-atempo-filter-be-in-the-0-5-2-0-range

JeremTM93 commented 12 months ago

Is the latest commit supposed to fix the multichannel sound blocking issue @kingslay ?Please update TracyPlayer 🙏

kingslay commented 12 months ago

Is the latest commit supposed to fix the multichannel sound blocking issue @kingslay ?Please update TracyPlayer 🙏

你说的这个问题是什么问题呢?是这个问题吗?

This comit has completely broken Spatial Audio for « AudioUnit » framework. Before the commit, at least, I could get spatial audio on ios.

JeremTM93 commented 12 months ago

Is the latest commit supposed to fix the multichannel sound blocking issue @kingslay ?Please update TracyPlayer 🙏

你说的这个问题是什么问题呢?是这个问题吗?

This comit has completely broken Spatial Audio for « AudioUnit » framework. Before the commit, at least, I could get spatial audio on ios.

https://github.com/kingslay/KSPlayer/issues/609#issuecomment-1793673277

https://github.com/kingslay/KSPlayer/issues/609#issuecomment-1793716746

kingslay commented 12 months ago

这个问题修复了。最新的testflight有修复了。

cdguy commented 12 months ago

I think the issue is more related to a UI glitch rather than a backend issue.

1- when I open my appleTV for the first time, the spatial audio fields are marked as “not available”

IMG_7373

2- when I open a stereo/multichannel audio file, the sound info is displayed as “multi-channel”; however I can’t access to the toggles.

IMG_7374 IMG_7375

As ios and tvos uses the same code, I guess the issue is related to UI rather than the code itself

I hope that helps! @kingslay

kingslay commented 12 months ago

@cdguy 在tvOS上要用AVSampleBufferAudioRenderer 这个音频类型才可以。在iOS没有这个限制。这是tvOS和iOS系统的区别