5 import java.io.FileInputStream;
6 import java.io.IOException;
7 import java.util.Properties;
8 import org.apache.commons.lang.StringUtils;
14 public class FfmpegOption {
16 private final String extOption;
17 private final String mainOption;
18 private final String inOption;
19 private final String outOption;
20 private final String avfilterOption;
21 private final boolean resize;
22 private final int resizeWidth;
23 private final int resizeHeight;
24 private final boolean adjustRatio;
26 public static FfmpegOption load(File file) throws IOException {
27 Properties prop = new Properties();
28 prop.loadFromXML(new FileInputStream(file));
29 String ext = prop.getProperty("EXT");
30 String main = prop.getProperty("MAIN", "");
31 String in = prop.getProperty("IN", "");
32 String out = prop.getProperty("OUT", "");
33 String avfilter = prop.getProperty("AVFILTER", "");
34 boolean resize = Boolean.getBoolean(prop.getProperty("RESIZE", "false"));
35 String width = prop.getProperty("WIDTH", "");
36 String height = prop.getProperty("HEIGHT", "");
37 boolean adjust = Boolean.getBoolean(prop.getProperty("ADJST_RATIO", "true"));
39 if (StringUtils.isBlank(ext)) {
40 throw new IOException("変換オプションファイル書式誤り ext: "
41 + ext + ", main: " + main + ", in: " + in + ", out: " + out + ", avfilter: " + avfilter);
43 return new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust);
46 public FfmpegOption(String extOption, String mainOption, String inOption, String outOption, String avfilterOption,
47 boolean resize, String width, String height, boolean adjust) {
48 this.extOption = (extOption.startsWith(".")) ? extOption : "." + extOption;
49 this.mainOption = mainOption;
50 this.inOption = inOption;
51 this.outOption = outOption;
52 this.avfilterOption = avfilterOption;
54 this.resizeWidth = (width.isEmpty()) ? 0 : Integer.parseInt(width);
55 this.resizeHeight = (height.isEmpty()) ? 0 : Integer.parseInt(height);
56 this.adjustRatio = adjust;
59 public String getExtOption() {
63 public String getMainOption() {
67 public String getInOption() {
71 public String getOutOption() {
75 public String getAvfilterOption() {
76 return avfilterOption;
79 public boolean isResize() {
83 public int getResizeWidth() {
87 public int getResizeHeight() {
91 public boolean isAdjustRatio() {