Discussion:
[Notepad-plus-plus] [notepad-plus - Plugin Development] Edit timecode in subtitle-files (.srt)
SourceForge.net
2008-04-18 07:43:25 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4912589
By: nobody

It would be great if someone would add a plugin to Notepad++ which could alter
all timecodes by a given amount of time... e.g.:
shift all values with 1,700 seconds
or
adjust all timecodes to a start and end time.
If I could I would have done it already ;)

grtz,
GraphMan

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=482781
SourceForge.net
2008-04-18 08:32:28 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4912689
By: nobody

Sure, I guess you do not have Excel on your computer?
'Cause if you would, you would have used that.


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=482781
SourceForge.net
2008-04-20 12:03:58 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4916193
By: nobody

I tried that before and had got some works.

My plugin can shift the timecode in the selected text by a shift_sec (shift
time in secs) in single or multiple files. I only tried it with my .ass files,
but if the timecode is in the format 0:00:00.00, it works.

There's a problem. For now, the way to adjust the shift_sec is using shift_sec++
or shift_sec-- and I must count the number of shift_sec by myself without any
hint or display because I don't know how to create a window or a message box
with input box. I tried to read the plugin template but still have no idea.

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=482781
SourceForge.net
2008-04-20 19:49:24 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4916686
By: nobody

If you read the times into an Excel sheet and copy the values to another column,
with number markup, can't you simply add your desired number of seconds (also
converted to a number) to the converted dates? You then only have to convert
the results back to a date format.


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=482781
SourceForge.net
2008-04-20 23:48:08 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4916945
By: nobody

I know excel can do that but it's too slow. Using notepad++ to open a subtitle
file is much faster than using excel.

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=482781
SourceForge.net
2008-04-21 07:20:18 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4917369
By: nobody

Whatever, if you want to use Notepad++ for it but you _can't_...


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=482781
SourceForge.net
2008-04-21 10:22:12 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4917737
By: nobody

I've written such AWK script a lot of time ago. It can shift time in .srt subtitles,
"compress" and "stretch" it. You can run AWK within Notepad++ using NppExec
plugin. The command line must be similar to this:

c:\progs\awk\awk95.exe -f srt_time.awk original_subtitles.srt

Here is the AWK script (srt_time.awk):

BEGIN {
TIME_CORR_COEFF = 1.0427 # time multiplier for compression/stretching
STR_TIME_CORR = "-00:00:00,800" # time shifting
OUTFILENAME = "_srt_time.out" # output file
CHAR_TIME_DIV = ":"
CHAR_TIME_MS_DIV = ","
STR_TIME_TO_TIME = "%s --> %s\n"
STR_TIME_HMSMS = "%02d%c%02d%c%02d%c%03d"
TIME_CORR_ACTION = substr(STR_TIME_CORR, 1, 1)
split(substr(STR_TIME_CORR, 2), a, CHAR_TIME_DIV)
TIME_CORR = hmsms_to_ms(a)
}

NR >= 1 {
i = 0
if (i = (split($1, a, CHAR_TIME_DIV) == 3)) {
s1 = CorrectTime(a)
if (i = (split($3, a, CHAR_TIME_DIV) == 3)) {
s2 = CorrectTime(a)
printf(STR_TIME_TO_TIME, s1, s2) > OUTFILENAME
}
}
if (!i) {
if (int($0) == 0) { print $0 > OUTFILENAME }
else { print int($0)-0 > OUTFILENAME }
}
}

function hmsms_to_ms(a, vt) {
h = int(a[1])
m = int(a[2])
vt = a[3]
split(vt, a, CHAR_TIME_MS_DIV)
s = int(a[1])
ms = int(a[2])
return (ms + 1000*(s + 60*(m + 60*h)))
}

function CorrectTime(a) {
time = int(TIME_CORR_COEFF*hmsms_to_ms(a))
if (TIME_CORR_ACTION == "+") { time += TIME_CORR }
else if (TIME_CORR_ACTION == "-") { time -= TIME_CORR }
b[1] = int(time/3600000)
time = time - b[1]*3600000
b[2] = int(time/60000)
time = time - b[2]*60000
b[3] = int(time/1000)
time = time - b[3]*1000
b[4] = time

return sprintf(STR_TIME_HMSMS, b[1], CHAR_TIME_DIV,
b[2], CHAR_TIME_DIV, b[3], CHAR_TIME_MS_DIV, b[4])
}


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=482781

Loading...