Looking for a movie, there are two video files in the Upper and Lower Sets. however, subtitle files are in SRT format. therefore, I wrote a program to split a subtitle file into two sets.
The usage is simple:
Adjsrt.exe sub_title.srt-hh: mm: SS
Sub_title.srt the subtitle file to be processed
-Hh: mm: SS: the time you want to subtract.-Is the minus sign, indicating that HH is a two-digit number, corresponding to the hour, mm corresponds to the minute, and SS corresponds to the second.
The program will print the processed results (in fact, the content of the SRT format subtitle file) to the screen. If you want to process the results directly generate the SRT file:
Adjsrt.exe sub_title.srt-hh: mm: SS> the SRT file to be generated. srt
For example, you need to divide a subtitle file that lasts for one hour into two subtitle files of each half hour. in fact, it is to output the subtitle file of the last half hour to another file, and the time labels of the subtitle are all less than half an hour.
You can do this:
Adjsrt.exe lasts for 1 hour. srt-00:30:00> 30 minutes later. srt
Download:
Executable program
Source code:
#include <cstdio>#include <cstring>#include <cstdlib>intmain(int argc, char** argv){char stime[]="-00:00:00";char* r;if(argc<=2){printf("%s/n","Usage: adjsrt.exe sub_title.srt -hh:mm:ss");return 0;}strncpy(stime,argv[2],9);stime[3]=stime[6]=0;char c=stime[0];const char* h=stime+1;const char* m=stime+4;const char* s=stime+7;int sec;sec=atoi(h)*60*60+atoi(m)*60+atoi(s);int from_sec;int to_sec;char prev[256]={0};char line[256]={0}; //256 is big enough for one line (even Chinese characters)char buf[256]={0};char from_mill[4]={0};char to_mill[4]={0};FILE* f=fopen(argv[1],"r");if(!f){printf("Failed to open %s!/n",argv[1]);return 1;}int cnt=1;do {r=fgets(line, sizeof(line)/sizeof(line[0]),f); if(!r) continue;if(!strstr(line," --> ")){strcpy(prev,line);continue;}strcpy(buf,line);buf[2]=buf[5]=buf[8]=buf[12]=buf[16]=buf[19]=buf[22]=buf[25]=0;from_sec=atoi(buf)*60*60+atoi(buf+3)*60+atoi(buf+6);to_sec=atoi(buf+17)*60*60+atoi(buf+20)*60+atoi(buf+23);if(from_sec>=sec){strncpy(from_mill,buf+9,3);strncpy(to_mill,buf+26,3);from_sec-=sec;to_sec-=sec;printf("%d/n",cnt);printf("%02d:%02d:%02d,%s --> %02d:%02d:%02d,%s/n",from_sec/3600,(from_sec%3600)/60,from_sec%60,from_mill,to_sec/3600,(to_sec%3600)/60,to_sec%60,to_mill);r=fgets(line, sizeof(line)/sizeof(line[0]),f); if(r)printf(line);printf("/n");cnt++;}}while(r); fclose(f);return 0;}