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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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:
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
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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])
}
Sure, I guess you do not have Excel on your computer?
'Cause if you would, you would have used that.
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.
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.
I know excel can do that but it's too slow. Using notepad++ to open a subtitle file is much faster than using excel.
Whatever, if you want to use Notepad++ for it but you _can't_...