Skip to content

[FEATURE] Support track language for Blu-ray disc from the MPLS STN table #527

Closed

Description

@bitxeno

What should the engine do?

For Blu-ray disc sources (ISO / BDMV), the engine should
read the disc's own per-stream language metadata — the ISO 639-2 codes stored in
the MPLS STNTable — and backfill TrackInfo.language by PID for tracks whose language is
und. This is the libbluray/VLC approach: those tools always show correct
languages for such discs because they read the BDMV metadata, not the PMT.

Motivating media or use case

Some Blu-ray ISO served over HTTP never support language-based auto-selection because these files typically have empty or undefined track languages. As a result, the engine’s languageMatches function does not consider them a match, regardless of the engine’s preferredSubtitleLanguages or the host-side preference settings.

Area

Codec / container support

Host app / integration context

No response

Would you be willing to open a PR?

No

Activity

  1. added
    enhancement
    on Sep 11, 2026
  2. superuser404notfound commented on Sep 11, 2026

    @superuser404notfound
    Owner

    Implemented and merged to main (6aa2716c), so this lands in the next release.

    The diagnosis here was exactly right, and worth restating because it is the whole reason the old behaviour could never be fixed downstream of the demuxer: a Blu-ray clip's PMT carries no ISO 639 language descriptor, so FFmpeg's mpegts demuxer sets no language metadata at all and every track arrives undetermined. languageMatches then correctly refuses to match, because there is genuinely nothing to match against. The languages only exist in the MPLS STN_table, which is where libbluray and VLC read them.

    What shipped:

    • Blu-ray: every PlayItem's STN_table is walked (past the 32 byte PlayItem header and any multi-angle block), collecting the ISO 639-2 code beside each stream's PID for audio, PG and IG entries. First declaration wins, since the demuxer opens on the first clip's PIDs. The walk stops after the IG group, because the secondary audio and video entries that follow carry extra attribute blocks, and a wrong guess there could only corrupt what came before.
    • DVD-Video, since the same hole is there and worse (VOBs carry no language anywhere in the bitstream): the VTS IFO audio and subpicture attribute tables, with the title's main program chain naming the substream number each attribute is actually carried as. That last part matters, audio_control / subp_control is not always the identity mapping, so a disc that authors its second audio attribute as substream 5 would otherwise have had its language attached to 0x81. A stream the chain marks absent is dropped, and without a readable chain the attribute's position is used, which is how the great majority of discs are authored.

    The table rides on the selected disc title, keyed by the AVStream.id FFmpeg reports for the container the title demuxes as (MPEG-TS PID on Blu-ray, MPEG-PS stream or substream start code on DVD), and it is applied in a single place in Demuxer. So it reaches the published audioTracks / subtitleTracks, preferredAudioLanguages / preferredSubtitleLanguages resolution, the native rendition table and the subtitle side demuxers together. Only an undetermined track is filled in: a language a container really declares stays authoritative.

    aetherctl disc-inspect <image> now prints what a disc declares per title, for example on the Blender Sintel Blu-ray:

    Titles:      1 (selected: 0)
      [0] dur=0:14:48  chapters=8
            languages: 0x1100=eng, 0x1200=ger, 0x1201=eng, 0x1202=spa, 0x1203=fre,
                       0x1204=ita, 0x1205=dut, 0x1206=pol, 0x1207=por, 0x1208=rus, 0x1209=vie
    

    which makes it possible to tell a disc whose tracks stay undetermined apart from a disc that declares nothing at all.

    One honest caveat on verification. The byte layouts are checked against libbluray's mpls_parse.c, libdvdread's ifo_types.h and VLC's dvdread_video.c rather than against my own fixtures, and the unit tests fail under mutation. On real media, that Sintel image resolves 11 languages out of its actual MPLS, matching what FFmpeg reports from the PMT stream for stream, which is a strong cross-check of the parse. But that disc does declare ISO 639 descriptors in its PMT, so for it the change is correctly a no-op. I have no image here that lacks them, which is precisely the shape described in this report, so a confirmation once the release is out would be very welcome. Leaving this open until then.

    Thanks for the report, and for pointing straight at the STN table rather than at the symptom.

  3. superuser404notfound commented on Sep 11, 2026

    @superuser404notfound
    Owner

    Released in 6.81.0 (6aa2716c, merged as 78bc9029). Both consumers are pinned to it.

    @bitxeno, an ISO's audio and subtitle tracks should now arrive with the languages the disc declares, so preferredAudioLanguages and preferredSubtitleLanguages can match one. aetherctl disc-inspect prints what a disc states per title, which separates a disc whose tracks stay undetermined from one that declares nothing.

  4. bitxeno commented on Sep 12, 2026

    @bitxeno
    Author

    I tried it, and the tracks have language now. Thanks!

  5. superuser404notfound commented on Sep 12, 2026

    @superuser404notfound
    Owner

    Thanks for confirming. That was the one case the change could not be verified here: the test image on hand declares its languages in the PMT as well, so on that disc the STN walk is correctly a no-op and only good as a cross-check. A disc that states them nowhere but the navigation data is what the parse was written for, and that is the case just covered.

    Closing on that. Thanks again for pointing straight at the STN table rather than at the symptom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions