/*
* Created on 2004/11/28
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.subtitle;
import java.io.File;
/**
*
*
*/
public class SubUtils {
public static int SUB=0;
public static int SRT=1;
public static final double NTSC_FRAME_RATE=29.97;
public static final double PAL_FRAME_RATE=25;
public static String[] getDefaultImageExtensions(){
return new String[]{".png",".gif",".bmp",".jpg"};
}
public static int getSubType(File file){
if(file.getName().toLowerCase().endsWith(".srt")){
return SRT;
}else{
return SUB;
}
}
public static long countContainTime(StandardSubObject object1,StandardSubObject object2){
long result=0;
for(long i=object1.getStartTime();i<=object1.getEndTime();i++){
if(i>=object2.getStartTime() && i<=object2.getEndTime()){
result++;
}
}
return result;
}
public static long getTotalTime(StandardSubObject[] subs){
long result=0;
for (int i = 0; i < subs.length; i++) {
result+=subs[i].getEndTime()-subs[i].getStartTime();
}
return result;
}
public static String toTimeString(long frame){
long hour=(long)(frame/(60*60*1000));
long remain=(long)(frame%(60*60*1000));
long minute=remain/(60*1000);
remain=remain%(60*1000);
long second=remain/1000;
remain=remain%1000;
String result="";
if(hour<10){
result="0"+hour;
}else{
result+=hour;
}
result+=":";
if(minute<10){
result+="0"+minute;
}else{
result+=minute;
}
result+=":";
if(second<10){
result+="0"+second;
}else{
result+=second;
}
long milli=remain*60/1000;
if(milli<10){
result+=":"+"0"+milli;
}
else{
result+=":"+milli;
}
return result;
}
}
|