ΤΣΑΤ
0.026
thk thk Τρι. 13 Μαϊος. 2008 15:20 tags προγραμματισμός , python 1 views
Of course there are numerous programs that adjust time on subtitle files, but here is a simple python script I have written one night I wasn't smart enough to search well. It adjusts time on srt files.

 Oh, and if you are on Windows try JetAudio media player which is very good in this task ( to sync unsychronized subtitles files with movies).
On Linux Kaffeine will do the job.
Save it as whatever_you_like.py and run it as
python program_name.py movie.srt 20   
(will move subtitles 20 seconds forward)
or
python program_name.py movie.srt -30   
(will move subtitles 30 seconds backward)

#!/usr/bin/env python
# By Thimios Katsoulis sometime in 2007 I think..
# Feel free to copy , modify , distribute

def toSeconds(s):
    secs=0
    secs +=int(s[6:])
    secs += int(s[3:5])*60
    secs += int(s[0:2])*60*60
    return secs
   
def toString(sec):
   
   
    h,sec = divmod(sec,3600)   
    m,s=divmod(sec,60)
    tim='%(h)02d:%(m)02d:%(s)02d' % {'h':h,'m':m,'s':s}
    return tim
   
   

if __name__ == '__main__':
    import sys

    subs=open(sys.argv[1])
    step=int(sys.argv[2])
    subOut=open(sys.argv[1] + str(step) + '.srt','wt')
   
    for l in subs.readlines():
        line=l
        if len(l) > 2:
            if l[2]==':' :
                line=''
                time1=l[:8]
                time2=l[17:25]
               
                secs1=toSeconds(time1)
                secs1 += step
                secs2=toSeconds(time2)
                secs2 += step
                tim1=toString(secs1)
                tim2=toString(secs2)
               
                line=tim1
                line += l[8:17]
                line +=tim2
                line += l[25:]
              
        subOut.write(line)       
       


   
   

As you see there is not a single check for argument count , their type e.t.c.
But I think it's amazing how small it is.
Python...

θυμήσου με
 
Am I evil?
2022-12-02 01:48
ο παπης
2022-10-26 21:04
Time to go
2022-10-26 19:34
αλληλεγγυη
2022-10-25 22:14
 
pepi γιά Time to go
2022-10-30 00:20
pepi γιά #152
2022-10-11 23:23
bou γιά #152
2022-10-11 00:20
Alpha γιά #2226
2022-10-06 22:47