Go Back   Forums > Community Chatterbox > Tech Corner > Programming
Memberlist Forum Rules Today's Posts
Search Forums:
Click here to use Advanced Search

Reply
 
Thread Tools Display Modes
Old 04-10-2008, 11:48 AM   #1
Playbahnosh
The Peacemaker
 
Playbahnosh's Avatar


 
Join Date: Apr 2005
Location: Veszprem, Hungary
Posts: 353
Send a message via MSN to Playbahnosh
Exclamation Looking for help with text-editing script

Hello!

I'm looking for someone with knowledge of a programming or scripting language (doesn't matter which one) for a small-time text editing job.

My problem is: I was making subtitles for a movie with a sub-making program, when something odd happened. Somehow the timing and the texts got messed up, desynchronized. I need someone to help me synch it back again.

For those, who are not familiar with the format of .srt files, here is a sample:
Code:
967
01:18:20,597 --> 01:18:23,854
Well, as history has shown,
nothing was further from the truth.
It consist of a number, two timecodes and some text. Basicly, just a bunch of these sections follow each other in the file. The number is the index of the current subtitle line. The two timecodes mark the beginning and end of the line's display time, basicly that line will be displayed in the duration between the two timecodes.

My actual problem is: the editor somehow messed up the relation between the text and the timings, essentially shifting the texts forward to the next timecode. So, timings and durations remained the same, but it displays the wrong texts, it always displays the previous line.
There is no feature in my sub-editor (or in any sub-editor, that I know of) to shift the texts back in place. So I either do it by hand, one line at a time, or I don't. And doing click-->crtl+X-->click-->crtl+V will drive me crazy, if I have to do all the 1463 lines by hand, one-by-one.

This is what I need help with. A small script or whatever, that copies the TEXT from the next timecode, and pastes it back into it's place, then does this for all the remaining lines, so the subtitle comes back into synch with the timecodes, like this:



For somebody, who is moderately proficient in some scripting or programming language, this shouldn't be too hard, I guess. Please help me!
__________________
The Master of Light and Darkness

"Don't fight the bad things in life! Find the good one! They are everywhere! Don't spend your life fighting for goals you can never reach! Live for the moment!"


BEWARE: I'm using the forums as a personal blog!
Playbahnosh is offline                         Send a private message to Playbahnosh
Reply With Quote
Old 04-10-2008, 12:03 PM   #2
_r.u.s.s.
I'm not Russ
but an ex-alektorophobic
 
_r.u.s.s.'s Avatar


 
Join Date: May 2005
Location: Nitra, Slovakia
Posts: 6,533
Default

try this

it has mass delay or other sync functinos
__________________
_r.u.s.s. is offline                         Send a private message to _r.u.s.s.
Reply With Quote
Old 04-10-2008, 01:14 PM   #3
Playbahnosh
The Peacemaker
 
Playbahnosh's Avatar


 
Join Date: Apr 2005
Location: Veszprem, Hungary
Posts: 353
Send a message via MSN to Playbahnosh
Default

Quote:
Originally Posted by _r.u.s.s. View Post
try this

it has mass delay or other sync functinos
Thanks, but it's no good. You see, the timings are all correct, THAT is the CORRECT part in the subtitle file, whats wrong are the texts, or more precisely the order of the texts.

um...lets put it like this: take two pieces of paper, put them beside each other so they touch. Now draw horizontal lines across the two papers, starting at the left side of the left paper and ending on the right side of the right paper, repeat this all the way to the bottom. Now write some time intervals (ex. "1:12pm to 2:32pm") on the lines on the left paper and write some text on the lines on the right paper. Now, slide the right paper down by one line, so the second timecode in the left paper comes in line with the first text on the right. THAT is my problem.

See, the timings and the intervals are all correct, but they have the wrong text to display, a one line lag. Now, all the subtitling programs I encountered have delay and sync features, but that's not what I need, because one line of subtitle and it's timecode are treated as one unit. Each line has it's timecode, and they are one unit of subtitle as far as the program is concerned. I can adjust the timing of ALL the wrong lines at once so the first one start to display at the intended time, but that, because the lines and their respective timecodes are being treated as a unit, won't do anything good, because the INTERVALS are still wrong.

You have that two papers still on the desk, align them again, first timecode to first line of text. Get another piece of paper, and put it beside the right one on the desk so they touch. Now you have 3 pieces of paper beside each other. Extend the lines to this new paper, and draw some pictures on the lines. This is the movie. Now slide the central paper (with the texts on it) down one line. Now you can see my problem. The timing is okay, but the wrong text is displayed. What the delay and sync feature in the programs does, is adjusting the text together with it's display interval. Now for the sync and time adjust: touch the left and the center paper, and slide them, TOGETHER, up or down, along the 'movie' paper. THAT'S what that feature does, but as you can see, it does not help my case, you see, because the start and end times of the subtitles are NOT IMPORTANT, just the INTERVAL, in which they are displayed.

Um...like this: you have your first line display two words for 0,5 sec, and the second line display two sentences for 5 sec. But it shifts one interval, so now it displays your two words for 5 sec, and your two sentences for God knows how long. Am I making any sense here?
__________________
The Master of Light and Darkness

"Don't fight the bad things in life! Find the good one! They are everywhere! Don't spend your life fighting for goals you can never reach! Live for the moment!"


BEWARE: I'm using the forums as a personal blog!
Playbahnosh is offline                         Send a private message to Playbahnosh
Reply With Quote
Old 04-10-2008, 01:35 PM   #4
_r.u.s.s.
I'm not Russ
but an ex-alektorophobic
 
_r.u.s.s.'s Avatar


 
Join Date: May 2005
Location: Nitra, Slovakia
Posts: 6,533
Default

oh, well i don't have any time to look at it right now, but if you have delphi7 that proggie is open source. and it has already preprogrammed classes for reading those blocks of text in srts, when it changing. if you could dig around it and move the text strings instead of changing the time, or changing those times to the previous value 1 position behind it, i guess it wouldn't have to be so difficult
__________________

Last edited by _r.u.s.s.; 04-10-2008 at 01:37 PM.
_r.u.s.s. is offline                         Send a private message to _r.u.s.s.
Reply With Quote
Old 04-10-2008, 03:10 PM   #5
Playbahnosh
The Peacemaker
 
Playbahnosh's Avatar


 
Join Date: Apr 2005
Location: Veszprem, Hungary
Posts: 353
Send a message via MSN to Playbahnosh
Default

If only I knew how to program in Delphi7

If I knew any programming or scripting languages that well, I would've done it myself, but sadly, I'm still only learning them, and the most complicated programs I can write are either display colored lines on the screen, or calculate something in the console window. Manipulating strings and files, and working with dense arrays are still beyond my abilities at this time. I COULD write the pseudo-code for the script/program, but I can't program it myself.

I think a sequential algorithm would work:

Code:
OPEN file
X=0
IF search string "-->" returns result
   THEN:
       move pointer to location
       go down one line
   ELSE:
      msg: "Wrong file"
      END PROGRAM
END IF
REPEAT UNTIL X=1
   IF search string "-->" returns result
      THEN:
         move pointer to location
         go down one line
         record location to variable SP
            IF search string "-->" returns result
               THEN:
                  move pointer to location
                  go down one line
                     REPEAT UNTIL encountering an empty line
                        record actual line to array L
                        DELETE actual line
                     END
                  move pointer to location SP
                     REPEAT UNTIL encountering an empty record in array L
                         insert respective line from array L to this location
                         new line
                      END
               ELSE:
                  END PROGRAM
            END IF
      ELSE:
         X=1
   END IF
END
SAVE file
CLOSE file
msg: "finished"
END PROGRAM
It's just an amateur sketch, but it might work...
__________________
The Master of Light and Darkness

"Don't fight the bad things in life! Find the good one! They are everywhere! Don't spend your life fighting for goals you can never reach! Live for the moment!"


BEWARE: I'm using the forums as a personal blog!
Playbahnosh is offline                         Send a private message to Playbahnosh
Reply With Quote
Old 04-10-2008, 03:19 PM   #6
_r.u.s.s.
I'm not Russ
but an ex-alektorophobic
 
_r.u.s.s.'s Avatar


 
Join Date: May 2005
Location: Nitra, Slovakia
Posts: 6,533
Default

easier would be storing the line containing the times (-->) and then replacing the next one with it
__________________
_r.u.s.s. is offline                         Send a private message to _r.u.s.s.
Reply With Quote
Old 04-10-2008, 03:35 PM   #7
Playbahnosh
The Peacemaker
 
Playbahnosh's Avatar


 
Join Date: Apr 2005
Location: Veszprem, Hungary
Posts: 353
Send a message via MSN to Playbahnosh
Default

...now that you mention it

But even if I know the algorithm and the pseudo-code, I don't know any programming language well enough to make it work...
__________________
The Master of Light and Darkness

"Don't fight the bad things in life! Find the good one! They are everywhere! Don't spend your life fighting for goals you can never reach! Live for the moment!"


BEWARE: I'm using the forums as a personal blog!
Playbahnosh is offline                         Send a private message to Playbahnosh
Reply With Quote
Old 05-10-2008, 10:51 AM   #8
arete
If All Else Fails, Play Dead
 
arete's Avatar


 
Join Date: May 2008
Location: Waterside, South Africa
Posts: 3,138
Default

Why don't you just use a video editing programme? It's what i'm learning to use... *drools at prospect of her own Liquid system w/ 3 screens and 4 speakers.*
__________________

"You have heard that it was said, 'You shall love your neighbor and hate your enemy.' But I say to you, love your enemies, bless those who curse you, do good to those who hate you, and pray for those who spitefully use you and persecute you..."
arete is offline                         Send a private message to arete
Reply With Quote
Old 05-10-2008, 11:50 AM   #9
_r.u.s.s.
I'm not Russ
but an ex-alektorophobic
 
_r.u.s.s.'s Avatar


 
Join Date: May 2005
Location: Nitra, Slovakia
Posts: 6,533
Default

video editing program? o_o he wanted to modify text strings in his srt, why would he edit video
__________________
_r.u.s.s. is offline                         Send a private message to _r.u.s.s.
Reply With Quote
Old 05-10-2008, 03:52 PM   #10
Playbahnosh
The Peacemaker
 
Playbahnosh's Avatar


 
Join Date: Apr 2005
Location: Veszprem, Hungary
Posts: 353
Send a message via MSN to Playbahnosh
Default

Okay, using _r.u.s.s.' idea, I created another pseudo-code, which replaces the timecodes instead of the subtitles themselves. Here:

Code:
OPEN file
X=0
IF search string "-->" returns result
   THEN:
       move pointer to location
       record line to variable T1
       delete line
       insert "00:00:00,000 --> 00:00:00,001"
       go down one line
   ELSE:
      msg: "Wrong file"
      END PROGRAM
END IF
REPEAT UNTIL X=1
   IF search string "-->" returns result
      THEN:
         move pointer to location
         record line to variable T2
         delete line
         insert line from variable T1
         move down one line
            IF search string "-->" returns result
               THEN:
                  move pointer to location
                  record line to variable T1
                  delete line
                  insert line from variable T2
                  move down one line
               ELSE:
                  X=1
            END IF
      ELSE:
         X=1
   END IF
END
SAVE file
CLOSE file
msg: "finished"
END PROGRAM
This is inarguably an easier method, and should be a cakewalk to put together, now.

Because the, fist line's timecode will be used as the second and the second's as the third...etc, I inserted a dummy timecode to the first line. By later deleting that line in-program, the indexing problem will be solved too.

A little help here?
__________________
The Master of Light and Darkness

"Don't fight the bad things in life! Find the good one! They are everywhere! Don't spend your life fighting for goals you can never reach! Live for the moment!"


BEWARE: I'm using the forums as a personal blog!
Playbahnosh is offline                         Send a private message to Playbahnosh
Reply With Quote
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Castlevania movie script revealed TheChosen Blah, blah, blah... 16 18-07-2008 06:41 PM
Abandonia Script? jourdan Old Suggestions 4 09-07-2007 09:24 AM
Script Not Working After Migrate Reup Old Suggestions 1 25-08-2006 11:58 AM
Annoying Script Prompt -RESOLVED guesst Old Suggestions 7 28-07-2006 01:00 AM


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump
 


The current time is 04:35 PM (GMT)

 
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.