Results 1 to 6 of 6

Thread: perl program to change subtitles help

  1. #1
    Join Date
    Apr 2008
    Beans
    46
    Distro
    Ubuntu 9.10 Karmic Koala

    perl program to change subtitles help

    I have a friend who is Greek and we are trying to get Greek subtitles for him. However, most of the "Greek" subtitles we find turn out to be something else. Like this:

    Code:
    δεν άντεχε τους αριθμούς μας,
    
    ήμασταν πολλοί.
    This is not Greek because it should look like this

    Code:
    δωδεκάδες πλανήτες
    και εκατοντάδες δορυφόροι.
    I am not sure if it a language problem with my computer or what????

    But a VERY few subtitles I find are greek. But they are not synced with the movie.

    So I though I would make a program that would just bump the timing up a second or two. However, no matter what I try I cannot get the text properly.

    A sample of the Subtitle I am trying to edit

    Code:
    1
    
    00:00:29,567 --> 00:00:30,761
     ( I can change the timing here)
    <i>H Τότε Γη...</i>
    
    
    
    2
    
    00:00:30,847 --> 00:00:33,839
    
    <i>δεν άντεχε τους αριθμούς μας,</i>
    
    <i>ήμασταν πολλοί.</i>
    
    
    
    3
    
    00:00:37,207 --> 00:00:39,323
    
    <i>Bρήκαμε ένα νέο</i>
    
    <i>ηλιακό σύστημα...</i>

    my Perl script
    Code:
    #!/usr/bin/perl
    
    $data = `cat SerenityDVD.srt`;
    
    
    @sp = split("\n",$data);
    
    print "<<<<<<<".$sp[5].">>>>>>>\n";

    The output of the program is this

    Code:
    >>>>>>>00:00:30,847 --> 00:00:33,839 
    Did not find string '-->' in
    00:00:30,847 --> 00:00:33,839
    >>>>>>>00:00:30,847 --> 00:00:33,839 should look like:

    Code:
    <<<<<<<00:00:30,847 --> 00:00:33,839>>>>>>>

    and it should have found "-->" in the string as well.

    Please anybody help

  2. #2
    Join Date
    Jan 2010
    Location
    opposing reality (VIC AU)
    Beans
    990
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: perl program to change subtitles help

    I reckon I know why your post is 12 hours old and has a lot more hits than replies but let's sort of ignore that right now.



    If you are talking about .avi/.mpg/.mp4 copies of movies you have downloaded from likes of btjunkie.org/isohunt.(???) or similar then you need to know that subtitles in such media cannot be removed (easily) nor replaced (any easier).

    If you are talking about DVD's in mplayer (or ~similar to mplayer) then maybe someone here can help but I see most likely you need to talk to the producer/distributor (not end distributor but company mentioned in credits of movie as distributor) of the DVD itself.
    NEED HELP? | [SOLVED] | MS hide
    A little nonsense now and then...
    .
    If this is a game thread and you are going to post I hope you have read the Original Post.

  3. #3
    Join Date
    Apr 2008
    Beans
    46
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: perl program to change subtitles help

    Yea I know why to lol. I wrote this really fast because I had someone waiting on me. Oh yea did I mention that I can't write.

    I use VLC player and it allows me to open subtitle files. It does not add the subtitle to the movie but just play it along side it.

    However, my problem comes twice.
    It's ether( and most of the time) the subtitles are not displayed properly like " δεν άντεχε τους αριθμούς μας " this when it should be this "και εκατοντάδες δορυφόροι"

    The other problem is that in the rare occasion that I find a actual Greek subtitle it is out of sync.

    Now it should not be that hard to re-sync it; but, because of the foreign text inside it is hard to build a perl program to edit all the lines.

    Lets say that $str = "00:00:30,847 --> 00:00:33,839"

    I grabed the whole file with $data = `cat file`

    well if I print the line like so

    print "The Line is:$data THis is the line";

    then it will look like this

    Code:
    This is the line 00:00:30,847 --> 00:00:33,839
    and you cant search the string for "-->" because its simply not there.

    The character encoding is keeping me from manipulating the text with perl properly.

    I have no clue what to do.

  4. #4
    Join Date
    Jan 2010
    Location
    opposing reality (VIC AU)
    Beans
    990
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: perl program to change subtitles help

    if you open the .srt (subtitles) file in gedit or (most likely) whatever you are using to edit your perl script and copy the '-->' from the subtitles file to your script using the system's copy and paste does that make your script able to find the correct characters?
    NEED HELP? | [SOLVED] | MS hide
    A little nonsense now and then...
    .
    If this is a game thread and you are going to post I hope you have read the Original Post.

  5. #5
    Join Date
    Apr 2008
    Beans
    46
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: perl program to change subtitles help

    No that does not work.

    Whats more if I do this

    Code:
    cat SerenityDVD.srt | more
    I get a blank screen no mater how far I go

  6. #6
    Join Date
    Apr 2008
    Beans
    46
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: perl program to change subtitles help

    I found the sulution. There is a weird character at the end of each line that I had to get delete.

    Code:
    #!/usr/bin/perl
    
    $data = `cat s.srt`;
    
    
    @sp = split("\n",$data);
    
    $tmp = $sp[5];
    chop($tmp); #delete that weird character
    
    print "<<<<<<<".$tmp.">>>>>>>\n";
    
    if($tmp =~ m/-->/g)
    {
    print "found";
    }
    Thanks for the help

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •