VideoHelp Forum
+ Reply to Thread
Results 1 to 25 of 25
Thread
  1. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Hi,

    I've managed to extract the subtitles for a TV show from my Sat Box.

    The subtitles are bunch of .png files.

    Around 300 files for each episode.

    The timing for those .png files is in the below format:

    Code:
    .
    .
    .
    <I s="10.510" e="13.320" x="276" y="472" w="202" h="46" i="AYZ-4.png" />
    <I s="13.490" e="16.490" x="244" y="469" w="266" h="42" i="AYZ-5.png" />
    .
    .
    .
    <I s="849.940" e="853.430" x="208" y="403" w="340" h="115" i="AYZ-206.png" />
    .
    I know that BDN (XML + PNG) subtitle format can be converted easily to idx/sub, but as you can see the timing format is seconds and milliseconds not like the usual timing format in BDN subtitles XML files which is HH:MM:SS:FF

    Any ideas or suggestions how I can convert those extracted subtitles into idx/sub format.

    Kind Regards,
    Mouna.
    Quote Quote  
  2. So, the only problem is the way the times are formated the rest would be fine?
    (converting seconds -> hh:mms:ff doesn't sound so hard)
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Originally Posted by Selur View Post
    So, the only problem is the way the times are formated the rest would be fine?
    (converting seconds -> hh:mms:ff doesn't sound so hard)
    Yes. I think I can take an existing valid XML subtitle file and replace the names of the images with the new images that I've got.

    The issue now will be to convert seconds to hh:mms:ff

    How this can be done in a systematic way.

    Kind Regards,
    Mouna.
    Quote Quote  
  4. Wrote a small quick&dirty console tool to convert such e="time in seconds" to e="hh:mm:ss:ff".
    Attached source code and 64bit Windows binary.

    What the program does is:
    1. read a file
    2. split it's content into lines
    3. check if line contains 'e="..."'
    4. convert the '...' from text to number
    5. convert the number to hh:mm:ss:ff
    6. replace '...' with the new 'hh:mm:ss:ff'
    7. save the file under a new name (= old name + _adjusted)

    Cu Selur
    Last edited by Selur; 11th Jul 2014 at 04:42.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  5. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Originally Posted by Selur View Post
    Wrote a small quick&dirty console tool to convert such e="time in seconds" to e="hh:mm:ss:ff".
    Attached source code and 64bit Windows binary.

    What the program does is:
    1. read a file
    2. split it's content into lines
    3. check if line contains 'e="..."'
    4. convert the '...' from text to number
    5. convert the number to hh:mm:ss:ff
    6. replace '...' with the new 'hh:mm:ss:ff'
    7. save the file under a new name (= old name + _adjusted)

    Cu Selur
    Thanks for your great help Selur.

    The timing in my file has two parts.

    Start of timing, s="

    and

    End of timing, e="

    you covered both or just the end?

    Kind Regards,
    Mouna.
    Quote Quote  
  6. just the end, gimme a second
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  7. attached a new version which should replace both e="..." and s="..." (didn't test it, but it should work)
    Last edited by Selur; 11th Jul 2014 at 06:44.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  8. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Originally Posted by Selur View Post
    attached a new version which should replace both e="..." and s="..." (didn't test it, but it should work)
    Thanks again Selur,

    It seems that the Start is still not included as shown in the below screenshot.

    Also, the resulting output file is empty.

    I've included both original file that has my timing and output file for your convenience, if you could take a look at them.

    Click image for larger version

Name:	Output.png
Views:	21
Size:	66.3 KB
ID:	26324

    I have another question regarding preparing the XML file.

    Appreciate if you or any generous member who has experience in those kind of issue would be kind to help me.

    The format of XML file should be as follow:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <BDN Version="0.93" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BD-03-006-0093b BDN File Format.xsd">
      <Description>
        <Name Title="Test._track3_eng_exp_exp" Content=""/>
        <Language Code="eng"/>
        <Format VideoFormat="1080p" FrameRate="23.976" DropFrame="False"/>
        <Events Type="Graphic" FirstEventInTC="00:01:01:22" LastEventOutTC="01:31:16:05" NumberofEvents="722"/>
      </Description>
      <Events>
        <Event InTC="00:01:01:22" OutTC="00:01:04:00" Forced="False">
          <Graphic Width="419" Height="59" X="750" Y="860">Test_0001.png</Graphic>
        </Event>
        <Event InTC="00:01:04:05" OutTC="00:01:05:17" Forced="False">
          <Graphic Width="255" Height="59" X="832" Y="860">Test_0002.png</Graphic>
        </Event>
    Now my file for the timing is as follow:

    Code:
    					<text>&lt;TimedImages targetWidth="720" targetHeight="576" aspectRatio="16:9"&gt;
    &lt;I s="0.600" e="3.720" x="268" y="458" w="218" h="58" i="AYZ1.png" /&gt;
    &lt;I s="3.840" e="6.960" x="290" y="400" w="176" h="111" i="AYZ2.png" /&gt;
    Is there an easy way to automate the process of converting the timing file into XML file.

    Thanks & Regards,
    Mouna.
    Attached Files
    Quote Quote  
  9. Ah mistake on my side I looked for '" s="'

    is there an easy way to automate the process of converting the timing file into XML file.
    Don't know any tool which does the conversion, so you would have to write one. Shouldn't be hard if you know how to do some programming.
    All in all it would require to:
    a. convert the input to proper xml (remove html escaping)
    b. read the xml into a dom structure
    c. parse the dom structure
    d. create a new dom structure which looks like the one you want
    e. write the output to a file.
    Probably one or may be two hours of work, assuming the programming language used offers some xml helper tools. If one would want to do it with in a bash or dos script it would probably take quite some time.

    Cu Selur

    Ps.: may be BDSup2Sub++ supports the format your sat box uses. (sadly it's not actively developed anymore otherwise it should have been easy for the author to add support for it)
    Attached Files
    Last edited by Selur; 11th Jul 2014 at 06:47.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  10. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Originally Posted by Selur View Post
    Ah mistake on my side I looked for '" s="' :)

    is there an easy way to automate the process of converting the timing file into XML file.
    Don't know any tool which does the conversion, so you would have to write one. Shouldn't be hard if you know how to do some programming.
    All in all it would require to:
    a. convert the input to proper xml (remove html escaping)
    b. read the xml into a dom structure
    c. parse the dom structure
    d. create a new dom structure which looks like the one you want
    e. write the output to a file.
    Probably one or may be two hours of work, assuming the programming language used offers some xml helper tools. If one would want to do it with in a bash or dos script it would probably take quite some time.

    Cu Selur

    Ps.: may be BDSup2Sub++ supports the format your sat box uses. (sadly it's not actively developed anymore otherwise it should have been easy for the author to add support for it)
    Thanks a lot for your help and support Selur :)

    Just one question regarding the time conversion.

    I noticed in some lines the time as follow:

    00:18:49:7

    00:19:54:3

    shouldn't there be 2 digits in the milliseconds part or it won't be a problem.

    Unfortunately, I don't have knowledge in programming, although I've studied Pascal Language in the University long long long time back :D

    Just to make it simple for anyone who has the capability to help, the requirement is only to convert each line in the attached file "test_f_adjusted.txt" to an equivalent line in XML.

    Below is an example:

    Code:
    &lt;I s="00:00:00:60" e="00:00:03:72" x="268" y="458" w="218" h="58" i="AYZ1.png" /&gt;
    This should be converted to the below 3 lines:

    Code:
        <Event InTC="00:00:00:60" OutTC="00:00:03:72" Forced="False">
          <Graphic Width="218" Height="58" X="268" Y="458">AYZ1.png</Graphic>
        </Event>

    Kind Regards,
    Mouna.
    Attached Files
    Quote Quote  
  11. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Hi,

    I did a lot of research and here is what I found.

    First, I've found the .XML file (attached) from my Sat Box.

    This XML file seems to be different than the XML file that is accepted by BDSup2Sub as shown in the below screen shot.

    Click image for larger version

Name:	Error.png
Views:	22
Size:	69.4 KB
ID:	26340

    It seems that BDSup2Sub accepts only Sony BDN XML files.

    As you can see from the comparison for the first few lines of each XML files (both attached as well) they are different.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <BDN Version="0.93" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BD-03-006-0093b BDN File Format.xsd">
      <Description>
        <Name Title="Test.1 - KRaLiMaRKo_track3_eng_exp_exp" Content=""/>
        <Language Code="eng"/>
        <Format VideoFormat="1080p" FrameRate="23.976" DropFrame="False"/>
        <Events Type="Graphic" FirstEventInTC="00:01:01:22" LastEventOutTC="01:31:16:05" NumberofEvents="722"/>
      </Description>
      <Events>
        <Event InTC="00:01:01:22" OutTC="00:01:04:00" Forced="False">
          <Graphic Width="419" Height="59" X="750" Y="860">Test_0001.png</Graphic>
        </Event>
        <Event InTC="00:01:04:05" OutTC="00:01:05:17" Forced="False">
          <Graphic Width="255" Height="59" X="832" Y="860">Test_0002.png</Graphic>
        </Event>
        <Event InTC="00:01:10:11" OutTC="00:01:12:09" Forced="False">
          <Graphic Width="662" Height="59" X="629" Y="860">Test_0003.png</Graphic>
        </Event>

    Code:
    <TimedImages targetWidth="720" targetHeight="576" aspectRatio="16:9">
    <I s="0.600" e="3.720" x="268" y="458" w="218" h="58" i="AYZ-1.png" />
    <I s="3.840" e="6.960" x="290" y="400" w="176" h="111" i="AYZ-2.png" />
    <I s="7.080" e="10.440" x="238" y="458" w="278" h="58" i="AYZ-3.png" />
    Now I would like some help to figure out:

    1. Is there any program/utility capable to convert the attached XML + PNG files into idx/sub file.

    2. Is there any program/utility capable to convert the attached XML file into Sony BDN XML file which BDSup2Sub can accept.

    Appreciate any help.

    Kind Regards,
    Mouna.
    Attached Files
    Quote Quote  
  12. Member
    Join Date: Jul 2011
    Location: Denmark
    Search Comp PM
    Originally Posted by MounaLafi View Post
    1. Is there any program/utility capable to convert the attached XML + PNG files into idx/sub file.

    2. Is there any program/utility capable to convert the attached XML file into Sony BDN XML file which BDSup2Sub can accept.
    You could try Subtitle Edit 3.4... right click in the list view in the ocr window, and choose Export -> ...
    Quote Quote  
  13. Attached a small tool for conversion AYZ.xml -> AYZ_adjusted.xml which should produce the needed output.

    Cu Selur
    Last edited by Selur; 17th Jul 2014 at 16:06.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  14. just out of curiosity: did XMLConverter help?
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  15. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Originally Posted by Selur View Post
    just out of curiosity: did XMLConverter help?
    Hi Selur,

    Sorry for the late reply.

    I tried the XML Converter and it seems that it will work, but it needs few modifications:

    1.

    This line:

    Code:
    <xml version="1.0" encoding="UTF-8"/>
    Should be modified to be:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    I'm gussing it is like a standard thing for XML files.

    2.

    The VideoFormat should be changed from:

    Code:
     <Format DropFrame="False" VideoFormat="576p" FrameRate="25"/>
    to:

    Code:
     <Format DropFrame="False" VideoFormat="720p" FrameRate="25"/>
    3.

    You didn't include the PNG files in the converted file :)

    This line & similar lines:

    Code:
     <Graphic Height="58" Width="218" X="268" Y="458"/>
    Should be:

    Code:
     <Graphic Height="58" Width="218" X="268" Y="458">AYZ-1.png</Graphic>
    4.

    The order in the Graphic Line should be:

    Code:
    <Graphic Width="419" Height="59" X="750" Y="860">Test_0001.png</Graphic>
    I noticed that you have put Height before Width, I don't know if this will make an issue or not.

    5.

    Whenever I tried your tool the order is becoming like this:

    Code:
    <Event Forced="False" InTC="00:00:21:80" OutTC="00:00:24:51">
       <Graphic X="208" Height="96" Y="415" Width="338"/>
    </Event>
    I don't know why this is happening, maybe I'm putting the command wrongfully.

    6.

    I didn't mention this before, but the PNG file is in the original XML file might be like below:

    i="Test/Test-1.png"

    Could the utility ignore the folder "Test" before the PNG file name, otherwise I have to create a folder with same name and put the XML + PNG files inside this folder.

    7.

    This is probably beyond the scope of the utililty, but I'm just mentioning as someone might help.

    I tried to fix those issues manually on the first few lines and then converted the XML + PNG files into idx/sub file.

    There are two issues:

    - Subtitles Size: they are smaller than usuall.

    - Subtitles Position: they were positioned above the middle of the left side of the screen.

    I tried to convert an existing idx/sub file to XML + PNG and then took the values of Width, Height, X and Y from the XML file and replaced the values in the generated XML file.

    This resulted for the subtitle size to increase a little bit and the subtitle position now became below the middle of the right side of the screen.

    I'm not sure what is the reason for this issue, I need to research a little bit regarding the values of Width, Height, X and Y in the XML file and their significant.

    Anyhow, thanks for your great help Selur.

    Kind Regards,
    Mouna.
    Quote Quote  
  16. Code:
     <Format DropFrame="False" VideoFormat="576p" FrameRate="25"/>
    will only be used if the resolution is 720x576, why would you specify 720p if you resolution isn't 1280x720?
    looking at the TimedImages info:
    Code:
    <TimedImages targetWidth="720" targetHeight="576" aspectRatio="16:9">
    the VideoFormat should be 576p


    About the order: xml documents normally have no order for their attributes -> order of attributes should not matter.
    About the image: Will fix that.
    Last edited by Selur; 17th Jul 2014 at 16:07.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  17. attached a version which when called with:
    Code:
    XMLConverter.exe "eng" "23.976" "720p" "PATH TO xml file"
    should:
    a. remove the path from the images
    b. set VideoFormat="720p"
    c. set FrameRate="23.976"
    d. set the header to:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    it does not reorder attributes, since XML does not require a specific order of attributes.
    Last edited by Selur; 17th Jul 2014 at 17:00.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  18. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Originally Posted by Selur View Post
    Code:
     <Format DropFrame="False" VideoFormat="576p" FrameRate="25"/>
    will only be used if the resolution is 720x576, why would you specify 720p if you resolution isn't 1280x720?
    looking at the TimedImages info:
    Code:
    <TimedImages targetWidth="720" targetHeight="576" aspectRatio="16:9">
    the VideoFormat should be 576p


    About the order: xml documents normally have no order for their attributes -> order of attributes should not matter.
    About the image: Will fix that.
    Hi Selur,

    Forgot to mention one more issue in few lines regarding the timing:

    Code:
    <I s="7.080" e="10.440" x="238" y="458" w="278" h="58" i="AYZ-3.png" />
    The timing is transferred to:

    Code:
     <Event InTC="00:00:07:8" OutTC="00:00:10:43" Forced="False">
    Is this going to caue an issue.

    Regards,
    Mouna.
    Quote Quote  
  19. it might,.. will look into it
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  20. should work now
    Attached Files
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  21. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Originally Posted by Selur View Post
    should work now
    Working like charm now Selur

    Many thanks for your great help.

    I'm working now to resolve the issue of Subtitles Position & Size.

    Kind Regards,
    Mouna.
    Quote Quote  
  22. my guess the problem is that the subtitles belong to SD content (according to your input xml) and you flag them as hd content.
    -> much luck
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  23. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Originally Posted by Selur View Post
    my guess the problem is that the subtitles belong to SD content (according to your input xml) and you flag them as hd content.
    -> much luck
    You are right. It is an SD content indeed.

    What do you suggest to be done?
    Quote Quote  
  24. Member
    Join Date: Dec 2008
    Location: Switzerland
    Search Comp PM
    Originally Posted by MounaLafi View Post
    Originally Posted by Selur View Post
    my guess the problem is that the subtitles belong to SD content (according to your input xml) and you flag them as hd content.
    -> much luck
    You are right. It is an SD content indeed.

    What do you suggest to be done?
    Nevermind Selur. I just figured it out & changed the video format to "576i" and this resolved my subtitle size and position issue

    Again, I can't thank you enough for your great support.

    Kind Regards,
    Mouna.
    Quote Quote  
  25. ah, 576i and not 576p like I guessed
    users currently on my ignore list: deadrats, Stears555
    Quote Quote