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 try (final FileInputStream fis = new FileInputStream(file)) {
29 prop.loadFromXML(fis);
31 String ext = prop.getProperty("EXT");
32 String main = prop.getProperty("MAIN", "");
33 String in = prop.getProperty("IN", "");
34 String out = prop.getProperty("OUT", "");
35 String avfilter = prop.getProperty("AVFILTER", "");
36 boolean resize = Boolean.getBoolean(prop.getProperty("RESIZE", "false"));
37 String width = prop.getProperty("WIDTH", "");
38 String height = prop.getProperty("HEIGHT", "");
39 boolean adjust = Boolean.getBoolean(prop.getProperty("ADJST_RATIO", "true"));
41 if (StringUtils.isBlank(ext)) {
42 throw new IOException("変換オプションファイル書式誤り ext: "
43 + ext + ", main: " + main + ", in: " + in + ", out: " + out + ", avfilter: " + avfilter);
45 return new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust);
48 public FfmpegOption(String extOption, String mainOption, String inOption, String outOption, String avfilterOption,
49 boolean resize, String width, String height, boolean adjust) {
50 this.extOption = (extOption.startsWith(".")) ? extOption : "." + extOption;
51 this.mainOption = mainOption;
52 this.inOption = inOption;
53 this.outOption = outOption;
54 this.avfilterOption = avfilterOption;
56 this.resizeWidth = (width.isEmpty()) ? 0 : Integer.parseInt(width);
57 this.resizeHeight = (height.isEmpty()) ? 0 : Integer.parseInt(height);
58 this.adjustRatio = adjust;
61 public String getExtOption() {
65 public String getMainOption() {
69 public String getInOption() {
73 public String getOutOption() {
77 public String getAvfilterOption() {
78 return avfilterOption;
81 public boolean isResize() {
85 public int getResizeWidth() {
89 public int getResizeHeight() {
93 public boolean isAdjustRatio() {