Code: Select all
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Properties;
import com.jamesmurty.utils.*;
public class Subbing {
public static void main(String[] args) throws Exception{
Properties outputProperties = new Properties();
PrintWriter writer = new PrintWriter(new FileOutputStream("projects.xspf"));
String[] locations = new String[] {
"file:///C:/Users/***/Downloads/***/BreakingBad English.mp4",
"file:///C:/Users/***/Downloads/***/BreakingBad French.mp4"};
String[] Str = new String[] {
"Dialogue: 0,0:03:36.75,0:03:39.29,Default,,0000,0000,000DD",
"Dialogue: 0,0:04:01.78,0:04:03.05,Default,,0000,0000,000DD",
"Dialogue: 0,0:04:25.67,0:04:26.87,Default,,0000,0000,000DD",
};
String Str2 = "";
XMLBuilder builder = XMLBuilder.create("playlist")
.a("versiom", "1")
.a("xmlns", "http://xspf.org/ns/0/")
.a("xmlns:vlc", "http://www.videolan.org/vlc/playlist/ns/0/")
.e("title")
.t("Liste de lecture").up()
.e("trackList");
for(int i=1; i < Str.length ; i++){
String firstnew = Str[i].substring(12, 22);
String secondnew = Str[i].substring(23, 33);
double firsthour = Double.parseDouble(firstnew.substring(0, 1));
double firstmin = Double.parseDouble(firstnew.substring(2, 4));
double firstsec = Double.parseDouble(firstnew.substring(5, 10));
double firstval = firsthour*60*60 + firstmin*60 + firstsec;
double secondhour = Double.parseDouble(secondnew.substring(0, 1));
double secondmin = Double.parseDouble(secondnew.substring(2, 4));
double secondsec = Double.parseDouble(secondnew.substring(5, 10));
double secondval = secondhour*60*60 + secondmin*60 + secondsec;
String firstold = Str[i-1].substring(12, 22);
double oldhour = Double.parseDouble(firstold.substring(0, 1));
double oldmin = Double.parseDouble(firstold.substring(2, 4));
double oldsec = Double.parseDouble(firstold.substring(5, 10));
double oldval = oldhour*60*60 + oldmin*60 + oldsec;
builder
.e("track")
.e("location")
.t(locations[0]).up()
.element("extension")
.a("application","http://www.videolan.org/vlc/playlist/0")
.e("vlc:option")
.t("start-time=" + oldval).up()
.e("vlc:option")
.t("stop-time=" + firstval).up()
.up();
builder
.e("track")
.e("location")
.t(locations[1]).up()
.element("extension")
.a("application","http://www.videolan.org/vlc/playlist/0")
.e("vlc:option")
.t("start-time=" + firstval).up()
.e("vlc:option")
.t("stop-time=" + secondval).up()
.up();
builder
.e("track")
.e("location")
.t(locations[0]).up()
.element("extension")
.a("application","http://www.videolan.org/vlc/playlist/0")
.e("vlc:option")
.t("start-time=" + secondval).up()
.e("vlc:option")
.t("stop-time=" + secondval+1).up()
.e("vlc:option")
.t("no-video").up()
.e("vlc:option")
.t("no-audio").up()
;
builder.up();
}
outputProperties.put(javax.xml.transform.OutputKeys.METHOD, "xml");
builder.toWriter(writer, outputProperties);
System.out.println(builder.asString(outputProperties));
}
}
Code: Select all
Dialogue: 0,0:03:36.75,0:03:39.29,Default,,0000,0000,000DD
Return to “Scripting VLC in lua”
Users browsing this forum: No registered users and 10 guests