2 Replies Latest reply on Aug 29, 2009 10:41 AM by aousabbas

    How to read SAMI subtitle files

    Federated Films Level 1
      Need to display subtitles under my QuickTime movies. Tried reading in a SAMI file, which is XML based, using Director's XMLparser Xtra, but it fails to parse it (though does not return an error). I can see this might be because the SAMI file has more than one root node and this obviously is breaking the parsing. Can anyone suggest a simple way for me to parse a SAMI file without having to hard code an entire TAG parsing system!

      Below is a chunck of the SAMI file as illustration.

      <SAMI>
      <HEAD>
      <STYLE TYPE="Text/css">
      <!--
      P {margin-left: 29pt; margin-right: 29pt; font-size: 36pt; text-align: center; font-family: Tahoma; font-weight: bold; color: #FFFFFF; background-color: #000000;}
      .SUBTTL {Name: 'Subtitles'; Lang: en-US; SAMIType: CC;}
      -->
      </STYLE>
      </HEAD>
      <BODY>
      <SYNC START=0>
      <P CLASS=SUBTTL>Thankfully, modern-day
      <SYNC START=2500>
      <P CLASS=SUBTTL> 
      <SYNC START=2601>
      <P CLASS=SUBTTL>spectacles look great.
      <SYNC START=5101>
      <P CLASS=SUBTTL> 
      <SYNC START=5202>
      <P CLASS=SUBTTL>However, they can be impractical.
      <SYNC START=8302>
      <P CLASS=SUBTTL> 
      </BODY>
      </SAMI>


        • 1. Re: How to read SAMI subtitle files
          Level 7
          MCR wrote:
          > Need to display subtitles under my QuickTime movies. Tried reading in
          > a SAMI file, which is XML based, using Director's XMLparser Xtra, but
          > it fails to parse it (though does not return an error). I can see
          > this might be because the SAMI file has more than one root node and
          > this obviously is breaking the parsing. Can anyone suggest a simple
          > way for me to parse a SAMI file without having to hard code an entire
          > TAG parsing system!
          >
          > Below is a chunck of the SAMI file as illustration.
          >
          > <SAMI>
          > <HEAD>
          > <STYLE TYPE="Text/css">
          > <!--
          > P {margin-left: 29pt; margin-right: 29pt; font-size: 36pt;
          > text-align: center; font-family: Tahoma; font-weight: bold; color:
          > #FFFFFF; background-color: #000000;}
          > .SUBTTL {Name: 'Subtitles'; Lang: en-US; SAMIType: CC;}
          > -->
          > </STYLE>
          > </HEAD>
          > <BODY>
          > <SYNC START=0>
          > <P CLASS=SUBTTL>Thankfully, modern-day
          > <SYNC START=2500>
          > <P CLASS=SUBTTL> 
          > <SYNC START=2601>
          > <P CLASS=SUBTTL>spectacles look great.
          > <SYNC START=5101>
          > <P CLASS=SUBTTL> 
          > <SYNC START=5202>
          > <P CLASS=SUBTTL>However, they can be impractical.
          > <SYNC START=8302>
          > <P CLASS=SUBTTL> 
          > </BODY>
          > </SAMI>

          I think that's too far removed from XML (no closing tags, no XML
          declaration) - but it looks like it would be easy to extract the parts you
          want with a regular expression, either in ECMAscript in Director or using
          the PRegEx xtra from openxtras.org.

          Andrew


          • 2. Re: How to read SAMI subtitle files
            aousabbas

            anyone was able to do this?