Skip to content
Snippets Groups Projects
exportAvi.ijm 886 B
Newer Older
Marius Hintsche's avatar
Marius Hintsche committed
//This macro should be called in Fiji's headless mode e.g.
// fiji --headless -macro /path-to-macro.ijm /path-to-file.tif
// or by runMacro(macro, arg)
// (apparently file path must be absolute)

frameRate = 20; // set fixed frame rate TODO: read time resolution and calculate frate 
outExtension = ".avi";

inFile = getArgument();
dotIndex = lastIndexOf(inFile, ".");
if (dotIndex >= 0) {
    baseName = substring(inFile, 0, dotIndex);
}
outFile = baseName+outExtension;
// escape spaces in path with \ and "" // does not work!
//outFile = "\"" + outFile + "\"";
//outFile = replace(outFile, " ", "\\\\\\\\ ");
if ( indexOf(outFile," ") >= 0 ) {
    exit("Input path must no contain whitespace!");
}
//print("will export to "+outFile);

setBatchMode(true);
open(inFile);
run("8-bit");
run("AVI... ", "compression=JPEG frame="+frameRate+" save="+outFile);
close();
setBatchMode(false);