Tab. wrote:I'm profoundly curious -- what's the use for VFAPI nowadays?Just about any program you'd be using accepts AVS input (some -- MeGUI and WMNicEnc, to name a few, only support avs input.)
Scintilla wrote:Wait, you're talking about DGVFAPI, the one that was supposed to have fixed the big problems of old regular VFAPI?
import java.io.File;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
/**
* A class that allows you to convert all DirectShow'able videos in a directory to vegas-importable avis.
* @author Ben Braun
*/
public class batchANYtoAVI {
public static void main(String[] args){
String absPath = "C:/Users/Ben Braun/Videos/AMVable Footage/Haruhi";
File in = new File(absPath);
if (!in.exists())
System.out.println("absPath invalid!");
Prepare(in);
for (File a : in.listFiles(new FilenameFilter(){
public boolean accept(File dir, String Filename){
String[] temp = Filename.split("\\.");
if (temp.length == 0)
System.out.println("In trying to test for directshowability, "+Filename+" had no extension." + temp.length);
String extension = temp[temp.length-1].toLowerCase(); //Note lower case
if (Filename.toUpperCase().contains("-FAKE"))
return false;
if (extension.equals("avi"))
return true;
if (extension.equals("mpg"))
return true;
if (extension.equals("mkv"))
return true;
if (extension.equals("ogm"))
return true;
return false;
}
})){
String namewext = a.getName();
String name = stripExtention(namewext);
String avsName = name + "-GENERATED.avs";
String aviName = name + "-FAKE.avi";
try {
File dir = new File("C:/Program Files/Avs2Avi");
File exe = new File(dir.getAbsolutePath()+File.separator+"avs2avi.exe");
if(!exe.exists())
System.err.println("Couldn't find avs2avi.exe" + exe.getAbsolutePath());
String targetAvs = absPath+"/"+avsName;
makeAvs(targetAvs, absPath+"/"+namewext);
if (!new File(targetAvs).exists())
System.err.println("Avs does not exist.");
String targetAvi = absPath+"/"+aviName;
File output = new File(targetAvi);
if (!output.exists()){
String Command = ""C:/Program Files/AVS2AVI/avs2avi.exe" ""+targetAvs+"" ""+targetAvi+""";
System.out.println(Command);
Process p = Runtime.getRuntime().exec(Command);
Thread.sleep(1000);
}
} catch (IOException e){
e.printStackTrace();
} catch (InterruptedException e){
e.printStackTrace();
}
}
}
public static String stripExtention(String FileNamewExtension){
char[] name = FileNamewExtension.toCharArray();
int lastLoc = -1;
for (int i = 0; i < name.length; i++)
if (name[i]=='.')
lastLoc = i;
if (lastLoc == -1)
return "";
else
return FileNamewExtension.substring(0,lastLoc);
}
public static void makeAvs(String avsFile, String srcFile){
try {
File target = new File(avsFile);
target.delete();
target.createNewFile();
FileWriter fw = new FileWriter(target);
fw.append("DirectShowSource(""+srcFile+"", audio=false, fps=29.970, convertfps=true)"+System.getProperty("line.separator"));
fw.append("Lanczos4Resize(720,480)"+System.getProperty("line.separator"));
fw.close();
} catch (IOException e){
e.printStackTrace();
}
}
public static void Prepare(File directory){
for (File a : directory.listFiles()){
String name = a.getName();
int lastLoc = -1;
char[] chars = name.toCharArray();
for (int i = 0; i < chars.length; i++){
if (i=='.')
lastLoc = i;
}
if (lastLoc == -1)
continue; //No periods in file, thats ok... I guess...
name = name.substring(0,lastLoc).replace('.', '_') + name.substring(lastLoc);
//System.out.println(name);
a.renameTo(new File(directory.getAbsolutePath()+"/"+name));
}
}
}
Zarxrax wrote:Oh, and by the way... I can't imagine that either makeavis, vfapi, or this avs2avi wrapper would be faster than any other. None of them are really adding any processing overhead onto the avs script except maybe colorspace conversions. If one is significantly slower than another, I can only imagine that something has gone terribly wrong, because they are all going to be limited by the speed of the underlying avs script.
Users browsing this forum: No registered users and 2 guests