Log in

View Full Version : feature request+suggest:subtitles auto-split


idanm19
16th May 2003, 01:37
I think someone I read a comment about that subtitles auto-split freature isn't implemented is that it calcs the cut point in frames (which can be found on the log file) and not in format of hh:mm:ss.ms. so I wrote a simple c++ program that calcs the apropriate string, and then running a bach is needed to perform the cutting, something like:

rundll32 vobsub.dll,Cutter %SUB_SRC% temp1 0 0:0:0.0 %CUT_POS%
rundll32 vobsub.dll,Cutter %SUB_SRC% temp2 1 %CUT_POS%

#include <iostream.h>

void int2str(int num, int digits_no, char* str)
{
int i, temp;
temp=num;
for (i=1; i<=digits_no; i++)
{
str[digits_no-i]=temp%10+'0';
temp=temp/10;
}
str[digits_no]=0;
}

void main()
{
long int frames_no;
float fps;
char str[14];
int hh,mm,ss,ms;
cout<<"please enter the frames number and the frame rate: ";
cin>>frames_no>>fps;
ss=(int)(((float)frames_no)/fps);
mm=ss/60;
hh=mm/60;
ms=((((float)frames_no)/fps)-ss)*1000;
ss=ss-mm*60;
mm=mm-hh*60;
cout<<hh<<":"<<mm<<":"<<ss<<"."<<ms<<endl;
int2str(hh,2,str);
int2str(mm,2,str+3);
int2str(ss,2,str+6);
int2str(ms,3,str+9);
str[2]=':';
str[5]=':';
str[8]='.';
cout<<str<<endl;
}

is it so difficult to make this feature work ?

len0x
16th May 2003, 12:02
if you guarantee that this code works, I'll try porting it to delphi...

idanm19
16th May 2003, 12:46
as far as I checked it works...
if you would like, I'll write a pascal (it's like delphi right ?) function that its input is frame_no, and fps, and it's output is a string which consist the appropriate string (hh:mm:ss.ms) or 4 integers (what output do you need for executing the script for the cutting process? I think a string will be more helpful here...)

procedure frames2timestr (frames_no:integer; fps:float; outstr:^char);

something like that ? (I don't remember exactly how to send an array to a function so I can change the array inside the function... and how long int called in pascal ? long integer ? )

here is the funtion in c++, tell me what you think...

#include <iostream.h>

void int2str(int num, int digits_no, char* str)
{
int i, temp;
temp=num;
for (i=1; i<=digits_no; i++)
{
str[digits_no-i]=temp%10+'0';
temp=temp/10;
}
str[digits_no]=0;
}

void frames2timestr (long int frames_no, float fps, char* outstr)
{
int hh,mm,ss,ms;
ss=(int)(((float)frames_no)/fps);
mm=ss/60;
hh=mm/60;
ms=((((float)frames_no)/fps)-ss)*1000;
ss=ss-mm*60;
mm=mm-hh*60;
int2str(hh,2,outstr);
int2str(mm,2,outstr+3);
int2str(ss,2,outstr+6);
int2str(ms,3,outstr+9);
outstr[2]=':';
outstr[5]=':';
outstr[8]='.';
}

void main()
{
long int frames_no;
float fps;
char str[14];
cout<<"please enter the frames number and the frame rate: ";
cin>>frames_no>>fps;
frames2timestr (frames_no,fps,str);
cout<<str<<endl;
}

len0x
16th May 2003, 13:56
I think what you've provided in C++ should be enough for me :)
(I can program in any language...)

idanm19
16th May 2003, 14:09
ok cool !