I dont know if this will help, but I had trouble when I wanted to adjust a .srt, seems like TimeAdjuster rounds up (
http://en.wikipedia.org/wiki/Rounding) the milliseconds value which in turn makes the sub slightly missaligned... the following code takes the millisecond value into account with no rounding... but maybe this isnt what you meant? the math you are asking for is in the code below... see the % 60 lines...
Code:
#include <windows.h>
#include <stdio.h>
void AdjustTime(char *Infile,char *Outfile,int time,BOOL add)
{
FILE *file,*fOut;
CHAR szBuf[1024] = {0};
CHAR szOut[1024] = {0};
fopen_s(&fOut,Outfile,"wb");
fopen_s(&file,Infile,"rb");
while(fgets(szBuf,1023,file)!=0) {
CHAR szFromHH[1024] = {0};
CHAR szFromMM[1024] = {0};
CHAR szFromSS[1024] = {0};
CHAR szFromNNN[1024] = {0};
CHAR szToHH[1024] = {0};
CHAR szToMM[1024] = {0};
CHAR szToSS[1024] = {0};
CHAR szToNNN[1024] = {0};
if(strstr(szBuf,"-->")) {
CHAR szTemp[1024] = {0};
strcpy_s(szTemp,szBuf);
char *pDest = 0;
while(pDest = strchr(szTemp,':')) {
pDest[0] = '\0';
if(szFromHH[0]==0) {
strcpy_s(szFromHH,szTemp);
strcpy_s(szTemp,&pDest[1]);
} else if(szFromMM[0]==0) {
strcpy_s(szFromMM,szTemp);
strcpy_s(szTemp,&pDest[1]);
if(pDest = strchr(szTemp,',')) {
pDest[0] = '\0';
strcpy_s(szFromSS,szTemp);
strcpy_s(szTemp,&pDest[1]);
if(pDest = strchr(szTemp,' ')) {
pDest[0] = '\0';
strcpy_s(szFromNNN,szTemp);
strcpy_s(szTemp,&pDest[5]);
}
}
} else if(szToHH[0]==0) {
strcpy_s(szToHH,szTemp);
strcpy_s(szTemp,&pDest[1]);
} else if(szToMM[0]==0) {
strcpy_s(szToMM,szTemp);
strcpy_s(szTemp,&pDest[1]);
if(pDest = strchr(szTemp,',')) {
pDest[0] = '\0';
strcpy_s(szToSS,szTemp);
strcpy_s(szTemp,&pDest[1]);
strcpy_s(szToNNN,szTemp);
}
}
}
int fromhh = atoi(szFromHH);
int frommm = atoi(szFromMM);
int fromss = atoi(szFromSS);
int fromnnn = atoi(szFromNNN);
int frommsecs = fromnnn+(fromss*1000)+((frommm*60)*1000)+(((fromhh*60)*60)*1000);
if(add)
frommsecs+=time;
else
frommsecs-=time;
int fhours = (frommsecs/3600000) % 60;
int fminutes = (frommsecs/60000) % 60;
int fseconds = (frommsecs/1000) % 60;
int fmillisecs = frommsecs % 1000;
int tohh = atoi(szToHH);
int tomm = atoi(szToMM);
int toss = atoi(szToSS);
int tonnn = atoi(szToNNN);
int tomsecs = tonnn+(toss*1000)+((tomm*60)*1000)+(((tohh*60)*60)*1000);
if(add)
tomsecs+=time;
else
tomsecs-=time;
int thours = (tomsecs/3600000) % 60;
int tminutes = (tomsecs/60000) % 60;
int tseconds = (tomsecs/1000) % 60;
int tmillisecs = tomsecs % 1000;
sprintf_s(szOut,"%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d",fhours,fminutes,fseconds,fmillisecs,thours,tminutes,tseconds,tmillisecs);
printf("%s\n",szOut);
fputs(szOut,fOut);
fputs("\r\n",fOut);
} else {
printf("%s\n",szBuf);
fputs(szBuf,fOut);
}
}
fclose(file);
fclose(fOut);
}
void main()
{
//adds 2000 ms (2 secs) to every timeline in the subtitle...
AdjustTime("C:\\mysubtitle.srt","C:\\mysubtitle2000added.srt",2000,TRUE);
//subtracts 1000 ms (1 secs) to every timeline in the subtitle...
AdjustTime("C:\\mysubtitle.srt","C:\\mysubtitle1000subtracted.srt",1000,FALSE);
}