Time manipulation in a file.
I am trying to edit a file with subtitle timers in it, and merge it with another one. The problem is, that the second file has timers that start again at 00:00:00,###. So I am trying to figure out how to edit the script to add an exact known time to the existing time in the second file.
Here is where the second file starts: 1 00:00:02,065 --> 00:00:03,225 My dear... 2 00:00:05,402 --> 00:00:07,927 You can't go to Okinawa like that. 3 I have to have the timers start at 01:10:04,000 for this second file and continue on with the times having been added to the 01:10:04,000, and I am at a complete blank on how to go about it. Can anyone point me in a direction? |
What language are you writing this in? In any case, many have libraries for handling dates & times, I'd expect that for each string/data that is a time from your second file, cast it and your offset time to a Date or Time or whatever class/data structure the libraries use, and then use it's method to add them to have calculated the shift. Then convert the result back to a string/whatever format your file's storing them in.
Basically you shouldn't need to reinvent the wheel just to add two numbers together that aren't simply base 10. |
I suggest you do some research on the subtitle editors that already exist. A quick search of apt brought up at least half-a-dozen for me. I'm sure at least a few of them have some kind of time-shift ability built-in.
Edit: Here's one example... http://docs.aegisub.org/manual/Shift_Times |
I was able to do it with Gnome-subtitles. Initially, I was trying to treat this problem as a raw text file. Thanks for reminding me it was not.
|
All times are GMT -5. The time now is 10:17 PM. |