36 lines
996 B
Java
36 lines
996 B
Java
package org.jcodec.movtool;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import org.jcodec.containers.mp4.MP4Util;
|
|
|
|
public class WebOptimize {
|
|
public static void main1(String[] args) throws IOException {
|
|
if (args.length < 1) {
|
|
System.out.println("Syntax: optimize <movie>");
|
|
System.exit(-1);
|
|
}
|
|
File tgt = new File(args[0]);
|
|
File src = hidFile(tgt);
|
|
tgt.renameTo(src);
|
|
try {
|
|
MP4Util.Movie movie = MP4Util.createRefFullMovieFromFile(src);
|
|
new Flatten().flatten(movie, tgt);
|
|
} catch (Throwable t) {
|
|
t.printStackTrace();
|
|
tgt.renameTo(new File(tgt.getParentFile(), tgt.getName() + ".error"));
|
|
src.renameTo(tgt);
|
|
}
|
|
}
|
|
|
|
public static File hidFile(File tgt) {
|
|
File src = new File(tgt.getParentFile(), "." + tgt.getName());
|
|
if (src.exists()) {
|
|
int i = 1;
|
|
do {
|
|
src = new File(tgt.getParentFile(), "." + tgt.getName() + "." + i++);
|
|
} while (src.exists());
|
|
}
|
|
return src;
|
|
}
|
|
}
|