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

Broken subtitle track names #710

Closed UnknownCoder807 closed 6 months ago

UnknownCoder807 commented 6 months ago

Describe the bug On my app and in tracyplayer, the names of the subtitles tracks are wrong. In the 2 images below, top one is tracyplayer, the 2nd one is the same movie in VLC.

Screenshots TracyPlayer tracyplayer

VLC vlc

kingslay commented 6 months ago

这个是因为字幕的 name 没有把languageCode 给加进去。可以提供url给我下。然后我调试下吗?或是你可以直接改FFmpegAssetTrack 这个类。 改下下面这个片段

  if let value = metadata["title"] {
            name = value
        } else {
            name = codecName
        }
        // AV_DISPOSITION_DEFAULT
        if mediaType == .subtitle {
            isEnabled = !isImageSubtitle || stream.pointee.disposition & AV_DISPOSITION_FORCED == AV_DISPOSITION_FORCED
            if stream.pointee.disposition & AV_DISPOSITION_HEARING_IMPAIRED == AV_DISPOSITION_HEARING_IMPAIRED {
                name += "(hearing impaired)"
            }
        }
FaiChou commented 6 months ago

name = codecName

建议metadata["title"]为空时候将 language 作为字幕的名字, 而不是codecName:

 if let value = metadata["title"] {
            name = value
        } else {
            name = languageCode ?? codecName
        }