Subtitles, WEBVTT? (1 Viewer)

pilehave

Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    Hi

    My site "DR TV" delivers subtitles for most streams, but I am not sure that OLV supports the format. They are in WebVTT format: https://w3c.github.io/webvtt/

    A real sample can be seen in http://www.dr.dk/mu-online/api/1.3/Asset?Id=56145cde6187a409d0bbe364

    The link may be geo-protected, but the format is really simple (only text, no markup or special codes):

    Code:
    WEBVTT
    
    00:00:11.560 --> 00:00:14.840
         Så er der nyt til folk,
         der skal til Solkysten.
    
    00:00:15.000 --> 00:00:18.920
        - Danske på Solkysten ...
      - En af de 30.000 danskere ...
    
    00:00:19.080 --> 00:00:24.040
          - Udlandsdanskere ...
    - Som har feriebolig i Spanien ...
    
    00:00:24.200 --> 00:00:30.320
        Solkysten. Costa del Sol.
       Hvor solbrændt kan det lyde?
    
    00:00:30.480 --> 00:00:36.000
    Er det ikke bare berusede danskere,
    som er flygtet fra slud og skat -
    
    00:00:36.160 --> 00:00:41.520
    - omgiver sig med salami, nægter
    at tale spansk og lever i ghettoer?
    
    00:00:44.280 --> 00:00:50.360
      Men hvad fordriver udvandrerne
    tiden med i en forstad til Malaga?
    
    00:00:50.520 --> 00:00:56.640
    Og hvad vil der ske, hvis man tager
         ned og kigger nogle dage?
    
    00:00:56.800 --> 00:01:01.800
          Er der noget at grine ad
    i denne lille, fjerne danskerkoloni?
    
    00:01:01.960 --> 00:01:07.080
    Og kan man vride bare et enkelt grin
    ud af de der danske i det spanske?

    I have tried to harcode the path into all videos with
    Code:
    video.SubtitleUrl = "http://www.dr.dk/mu-online/api/1.3/Asset?Id=56145cde6187a409d0bbe364";
    but it doesn't work.

    Do I need to do more to get it working? Is the format accepted in OLV?
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #2
    Ok, seems that WebVTT needs to be converted to SRT, luckily you did all the hard work for me, building a converter :love:

    So, I converted my loadAsset function to a tuple (in order to be able to return two values from same call). In this, I added the magic subtitle download:

    Code:
          JArray subtitleLinks = (JArray)objuri["SubtitlesList"];
          string subtitleText = "";
          foreach (JObject link in subtitleLinks)
          {
            Log.Debug("DR TV subtitle found:" + link.ToString());
            string webDataUrl2 = (string)link["Uri"];
            Log.Debug("DR TV subtitle uri:" + webDataUrl2);
            subtitleText = Helpers.SubtitleUtils.Webvtt2SRT(GetWebData(webDataUrl2));
          }

    So, loadAsset is called from GetVideoUrl, the subtitle is assigned with video.SubtitleText and loadAsset returns the videolink (as it did before):

    Code:
            Tuple<string, string> link = loadAsset(video.VideoUrl);
            video.SubtitleText = link.Item2;
            return link.Item1;

    Seems to work really well :D
     

    doskabouter

    Development Group
  • Team MediaPortal
  • September 27, 2009
    4,583
    2,972
    Nuenen
    Home Country
    Netherlands Netherlands
    One remark though: I've jiust improved the implementation of Webvtt2SRT to work on some kinds of WebVTT files (the kind with sequence numbers before each block) so if you encounter those, you'll have to wait for a new release of onlinevideos to work properly
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #4
    Thanks, but they seem to be working just fine with the format being used, so I'm a happy camper :)

    BTW; I saw that subtitles are enabled by default when I play a video from OLV, is this a setting controlled in MediaPortals subtitle-section, or is this a setting in OLV?
     

    Users who are viewing this thread

    Top Bottom