2 package saccubus.worker.classic.profile;
5 import java.io.FileInputStream;
6 import java.io.IOException;
7 import java.util.Properties;
8 import org.apache.commons.lang.StringUtils;
9 import saccubus.worker.profile.GeneralProfile;
15 public class FfmpegOption implements saccubus.worker.profile.FfmpegProfile {
17 private final String extOption;
18 private final String mainOption;
19 private final String inOption;
20 private final String outOption;
21 private final String avfilterOption;
22 private final boolean resize;
23 private final int resizeWidth;
24 private final int resizeHeight;
25 private final boolean adjustRatio;
27 public static FfmpegOption load(File file) throws IOException {
28 Properties prop = new Properties();
29 prop.loadFromXML(new FileInputStream(file));
30 String ext = prop.getProperty("EXT");
31 String main = prop.getProperty("MAIN", "");
32 String in = prop.getProperty("IN", "");
33 String out = prop.getProperty("OUT", "");
34 String avfilter = prop.getProperty("AVFILTER", "");
35 boolean resize = Boolean.getBoolean(prop.getProperty("RESIZE", "false"));
36 String width = prop.getProperty("WIDTH", "");
37 String height = prop.getProperty("HEIGHT", "");
38 boolean adjust = Boolean.getBoolean(prop.getProperty("ADJST_RATIO", "true"));
40 if (StringUtils.isBlank(ext)) {
41 throw new IOException("変換オプションファイル書式誤り ext: "
42 + ext + ", main: " + main + ", in: " + in + ", out: " + out + ", avfilter: " + avfilter);
44 return new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust);
47 public FfmpegOption(String extOption, String mainOption, String inOption, String outOption, String avfilterOption,
48 boolean resize, String width, String height, boolean adjust) {
49 this.extOption = (extOption.startsWith(".")) ? extOption : "." + extOption;
50 this.mainOption = mainOption;
51 this.inOption = inOption;
52 this.outOption = outOption;
53 this.avfilterOption = avfilterOption;
55 this.resizeWidth = (width.isEmpty()) ? 0 : Integer.parseInt(width);
56 this.resizeHeight = (height.isEmpty()) ? 0 : Integer.parseInt(height);
57 this.adjustRatio = adjust;
62 public String getExtOption() {
67 public String getMainOption() {
72 public String getInOption() {
77 public String getOutOption() {
82 public String getAvfilterOption() {
83 return avfilterOption;
87 public boolean isResize() {
92 public int getResizeWidth() {
97 public int getResizeHeight() {
102 public boolean isAdjustRatio() {