[Approved] Teletext subtitle page based on Service Information (1 Viewer)

jblomb

Retired Team Member
  • Premium Supporter
  • May 17, 2007
    96
    17
    Sundsvall
    Home Country
    Sweden Sweden
    Hi again.

    Below is a patch that adds support for selecting the correct teletext subtitle page based on the Service Information packets in the TS stream.

    Right now MP uses flags from the teletext stream itself to find the subtitle page and language, but on many channels this is not enough. SVT uses the same teletext stream for several channels, and the same goes for TV4. TCM Nordic has a couple of swedish subtitle pages and one of them just shows garbled text. MP often finds the wrong subtitle page, and shows subtitles belonging to another channel, or shows hard-of-hearing subtitles when I don't want them.

    In the TS service information packets it is listed which subtitle pages are available, in which language, and if they are hard-of-hearing subs. This patch checks those entries against language preferences and saves the correct subtitle page number. SubtitleSelector never need to check the teletext flags - it can just use the saved page number instead. The patch only checks for teletext subtitle type 2, but it wouldn't be hard to add a checkbox "Display hard-of-hearing subs" to TVClient config and if the checkbox is checked - also include type 5 subs.

    The patch is made against Mediaportal git 1.2.0.142.

    :D for a great program.
     

    Attachments

    • SubtitleSelector.diff
      1.9 KB
    • TSReaderPlayer.diff
      2 KB
    • TeletextReceiver.diff
      2.5 KB
    Last edited by a moderator:

    Wbunaarf

    Portal Pro
    December 9, 2005
    534
    103
    Sweden
    Home Country
    Sweden Sweden
    Hi,

    MP often finds the wrong subtitle page, and shows subtitles belonging to another channel, or shows hard-of-hearing subtitles when I don't want them.

    I can of course confirm this very annoying problem. To be fair though some STBs and TVs show the same behaviour).

    In the TS service information packets it is listed which subtitle pages are available, in which language, and if they are hard-of-hearing subs. This patch checks those entries against language preferences and saves the correct subtitle page number. SubtitleSelector never need to check the teletext flags - it can just use the saved page number instead. The patch only checks for teletext subtitle type 2, but it wouldn't be hard to add a checkbox "Display hard-of-hearing subs" to TVClient config and if the checkbox is checked - also include type 5 subs.

    Is the information which page belongs to which channel available? If so it would be very nice not to see the irrelevant pages at all in the list. Also, perhaps rather than just the page number the language could be shown as well like 'Swe (199)'. Regarding the 'hard-of-hearing subs' I'm not sure if it really needs to be added as an option in config, but it would be nice if it was shown in the menu that it's not 'ordinary' subtitles (no, I'm not sure how. 'Swe (199) - HoH'?).

    Apart from that, I've applied the patch and I can confirm that I no longer get the wrong subtitles on SVT. I haven't (yet) found any problems.

    //W
     

    jblomb

    Retired Team Member
  • Premium Supporter
  • May 17, 2007
    96
    17
    Sundsvall
    Home Country
    Sweden Sweden
    The information is stored in the Service Information stream, and it points out the subtitle page for that channel only.

    eg in the log for for SVT2 regarding Service Information:

    2012-01-27 17:17:40.265625 [Debug][(62)]: Page 692 is of type 2 and in lang swe
    2012-01-27 17:17:40.265625 [Debug][(62)]: Found preferred subtitle language swe on page 692 with index 0
    2012-01-27 17:17:40.265625 [Debug][(62)]: Page 592 is of type 2 and in lang dan
    2012-01-27 17:17:40.265625 [Debug][(62)]: Page 792 is of type 5 and in lang swe

    and regarding the lang info in the teletext stream:

    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 794 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 795 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang dan page : 592 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 793 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang swe page : 691 Pref index 0
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang swe page : 692 Pref index 0
    2012-01-27 17:17:59.921875 [Debug][(62)]: Setting as pref
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 693 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 694 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 788 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 791 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 792 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 796 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 797 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 198 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 299 Pref index -1

    If not for the patch, MP would have chosen page 691 which is the subtitle stream for SVT1.

    I can think of one drawback - the selection won't work on analogue channels. However, I don't think selection based on flags in the teletext stream is the correct way to go anyway. In this particular example, the wrong sub would have been chosen for the analogue channel.

    I will check if I can change what is listed in the menu as well.

    /Blomman
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    It would be better that

    Code:
    +          using (MPSettings xmlreader = new MPSettings())
    +              xmlreader.RemoveEntry("tvservice", "dvbdefttxtsubtitles");

    Type of code wouldn't be executed on run time. It should be done only one to remove the old setting - preferably when user opens the configuration.exe.

    Also if possible switch your local version control to use GIT and base the patches on that, as we have been using GIT already for months so we cannot apply those patches directly but instead would need manually to copy content.
     

    jblomb

    Retired Team Member
  • Premium Supporter
  • May 17, 2007
    96
    17
    Sundsvall
    Home Country
    Sweden Sweden
    Actually - I am using MPSettings because I couldn't find any way to pass these values between classes. Especially since OnServiceInfo is a callback routine. :)
    If anyone has a better solution I'll be very happy.
    Instead of removing the setting completely, I can change the page number to 0.

    I knew how to use SVN, but I will have to learn GIT. However, I am using GIT and I am making the diffs from TortoiseGIT, but I suppose I should do it in a different way.
     

    Wbunaarf

    Portal Pro
    December 9, 2005
    534
    103
    Sweden
    Home Country
    Sweden Sweden
    The information is stored in the Service Information stream, and it points out the subtitle page for that channel only.

    eg in the log for for SVT2 regarding Service Information:

    2012-01-27 17:17:40.265625 [Debug][(62)]: Page 692 is of type 2 and in lang swe
    2012-01-27 17:17:40.265625 [Debug][(62)]: Found preferred subtitle language swe on page 692 with index 0
    2012-01-27 17:17:40.265625 [Debug][(62)]: Page 592 is of type 2 and in lang dan
    2012-01-27 17:17:40.265625 [Debug][(62)]: Page 792 is of type 5 and in lang swe

    and regarding the lang info in the teletext stream:

    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 794 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 795 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang dan page : 592 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 793 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang swe page : 691 Pref index 0
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang swe page : 692 Pref index 0
    2012-01-27 17:17:59.921875 [Debug][(62)]: Setting as pref
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 693 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 694 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 788 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 791 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 792 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 796 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 797 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 198 Pref index -1
    2012-01-27 17:17:59.921875 [Debug][(62)]: Teletext Lang page : 299 Pref index -1

    If not for the patch, MP would have chosen page 691 which is the subtitle stream for SVT1.

    Humm... As far as I know SVT don't use DVB text and for the last 30 years or so page 199 has been subtitles for SVT1. What is 691?

    What I meant with only showing the relevant pages was that for SVT1 only 199 should be an option, for SVT2 299 and so on, but according to your logs above that doesn't seem possible...

    I will check if I can change what is listed in the menu as well.

    Nice!

    While you're at it, I see some strange behaviour here. It might not be related to your patch, but still...

    1. Start TV fresh and go to eg SVT1
    2. Bring up the subtitle menu (F9/subtitles) and notice how many different subtitles there are
    3. Change nothing but rather just close the menu (esc)
    4. Bring up the subtitle menu again and notice that the number of available subtitles has changed

    I can reproduce this behaviour every time and on both DVB-S and DVB-T.

    //W
     

    jblomb

    Retired Team Member
  • Premium Supporter
  • May 17, 2007
    96
    17
    Sundsvall
    Home Country
    Sweden Sweden
    Humm... As far as I know SVT don't use DVB text and for the last 30 years or so page 199 has been subtitles for SVT1. What is 691?

    True - SVT don't use DVB subtitles, but this patch is for teletext subs. It just checks the info transmitted in the DVB stream which teletext pages contains subtitle information for this channel.
    The pages 199 and 299 are the teletext pages you are prompted on screen to use if you want to add subtitles to a show, eg hard-of-hearing subs. 691 is the normal translated subtitle, like they are used in Canal+. Usually SVT "burns" the swedish subtitles into the film/show itself, so there will not be any need for teletext subtitles.
    If I remember correctly in the example above - page 299 and page 792 shows the same subtitle. I will check when there is a chance. :)

    1. Start TV fresh and go to eg SVT1
    2. Bring up the subtitle menu (F9/subtitles) and notice how many different subtitles there are
    3. Change nothing but rather just close the menu (esc)
    4. Bring up the subtitle menu again and notice that the number of available subtitles has changed

    Everytime a subtitle page is found according to the flags in the teletext stream, it is added to the menu. It takes some time for all teletext pages to be processed, so it will take some time before all subtitle pages are added to the menu.

    BR
    /Blomman

    Updated Diffs in first post.
    Also created a pull request in github: https://github.com/MediaPortal/MediaPortal-1/pull/5
     

    Wbunaarf

    Portal Pro
    December 9, 2005
    534
    103
    Sweden
    Home Country
    Sweden Sweden
    It just checks the info transmitted in the DVB stream which teletext pages contains subtitle information for this channel.

    So, would it be possible to hide the other pages (eg 793 - SVTB/24, 794 - Kunskapskanalen - and so on when watching SVT1)? It would be nice if possible, but perhaps it could cause problems on other channels (if the above information isn't mandatory or simply wrong in the stream)?

    Everytime a subtitle page is found according to the flags in the teletext stream, it is added to the menu. It takes some time for all teletext pages to be processed, so it will take some time before all subtitle pages are added to the menu.

    Indeed. If waiting a bit longer before opening the menu it is fully populated.

    Updated Diffs in first post.
    Also created a pull request in github: https://github.com/MediaPortal/MediaPortal-1/pull/5

    Applied and seems to still be working fine (I didn't check for changes). It is soo nice not having live subtitling from the news on SVTB... :)

    //W
     

    jblomb

    Retired Team Member
  • Premium Supporter
  • May 17, 2007
    96
    17
    Sundsvall
    Home Country
    Sweden Sweden
    :D

    Updated patches in 1st post. If service information packets lists the subtitle page in the 001-099 range, it is supposed to be in the 800-899 range according to ETS standard. See discussion and earlier patch for a similar problem at https://forum.team-mediaportal.com/...ience-fiction-no-def-subtitle-language-79141/
    I should have remembered that earlier ;)
    The problem can easily be spotted on BBC Entertainment, where the swedish subs are on page 887.

    Code:
    2012-02-04 10:13:35.174889 [Debug][(13)]: Page 85 is of type 2 and in lang dan
    2012-02-04 10:13:35.175888 [Debug][(13)]: Page 86 is of type 2 and in lang nor
    2012-02-04 10:13:35.175888 [Debug][(13)]: Page 87 is of type 2 and in lang swe
    2012-02-04 10:13:35.176888 [Debug][(13)]: Found preferred subtitle language swe on page 87 with index 0
    2012-02-04 10:13:35.176888 [Debug][(13)]: Page 88 is of type 2 and in lang fin
     

    Users who are viewing this thread

    Top Bottom