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
886 stars 184 forks source link

Audio stops on streams if it changes from 2.0 to 5.1 #644

Closed edge261 closed 7 months ago

edge261 commented 8 months ago

Describe the bug Some streams have different audio configs depending on the content that the channel is broadcasting at the moment, so an ad could be 2.0 and the show itself is 5.1. When the stream is opened, and 5.1 audio is available, it will switch to 2.0 in the ad break seamlessly, but after the ad break, it should go back to 5.1 and instead, no audio is being sent to the tv or audio receiver. Reopening the stream will give the audio back, but will happen again.

To Reproduce Steps to reproduce the behavior:

  1. Open a stream with 5.1 audio
  2. Wait for an ad break (usually ads are in stereo)
  3. after the ad break, just silence.

Expected behavior Clean switch between audio sources.

Screenshots If applicable, add screenshots to help explain your problem.

Platform (please complete the following information):

kingslay commented 8 months ago

可以提供下视频片段吗

edge261 commented 8 months ago

可以提供下视频片段吗

let me try to get a clip, i don't know if ffmpeg will catch the change from 2.0 to 5.1 and adjust...

edge261 commented 8 months ago

thanks @kingslay , seems to be fixed.

however, it drops frames when the switch is made (it was happening before this broke) ... is it expected, or is it a bug?

kingslay commented 8 months ago

这是不符合预期的,这个丢帧是丢视频帧还是音频帧呢?是会丢多久呢?

edge261 commented 8 months ago

This is not expected, is this lost frame a video frame or an audio frame? How long will it take to lose it?

both, but I believe the video frame loss is more noticeable since it takes a second to recover. (even appears the spinning wheel loading for a bit)

in the audio i just notice a quick mute (and i'm not sure if it's because of my soundbar).

kingslay commented 8 months ago

你可以试下 KSOptions.audioPlayerType=AudioUnitPlayer.self 。然后看会不会有这个问题

edge261 commented 7 months ago

你可以试下 KSOptions.audioPlayerType=AudioUnitPlayer.self 。然后看会不会有这个问题

Well, tried to change the audio mode in TracyPlayer to AudioUnit and still get the same 17 dropped frames, and the audio switch being sloppy...

However, in another app that uses KSplayer, it works flawlessly.

So far, I will consider this bug as solved. If it reappears in the future on another app that's not TracyPlayer, I'll let you know.

edge261 commented 7 months ago

Sorry to bring it back again.

I'm checking on a UHD stream and I get lost frames when the audio switches...

Hard to reproduce because not many channels does what this channel do with ads.

Probably will just deal with it until I can find a way to show @kingslay what is happening.

kingslay commented 7 months ago

用其他的播放器也会有这个问题吗?例如mpv

edge261 commented 7 months ago

用其他的播放器也会有这个问题吗?例如mpv

Unable to test in MPV because in tvOS the media appears as a blue screen.

Will try with VLC.

@kingslay sent you an email with useful stuff for this.

cdguy commented 7 months ago

Hard to reproduce because not many channels does what this channel do with ads.

@kingslay please try with the last stream link I shared with you (SDR BT.709)

When I change the audio track using the last tracyplayer on ios, the image freezes, however the audio track continues to play

cdguy commented 7 months ago

@kingslay can you please update tracy player? I am sure @djokt and @JeremTM93 would want to try it

djokt commented 7 months ago

@kingslay can you please update tracy player? I am sure @djokt and @JeremTM93 would want to try it

As soon as it's available, I'll give it a try and report back here.

kingslay commented 7 months ago

已经更新了test flight了