OSDN Git Service

merge
[coroid/inqubus.git] / frontend / src / saccubus / properties / MovieSetting.java
1 /* $Id$ */
2 package saccubus.properties;
3
4 import java.io.File;
5 import java.util.Properties;
6 import saccubus.converter.profile.FfmpegOption;
7
8 /**
9  * \93®\89æ\90Ý\92è.
10  * @author yuki
11  */
12 public class MovieSetting {
13
14     private static final String PROP_FFMPEG_PATH = "FFnpegPath";
15     private static final String PROP_VHOOK_PATH = "VhookPath";
16     private static final String PROP_OPTION_FILE = "OptionFile";
17     private static final String PROP_CMDLINE_EXT = "CMD_EXT";
18     private static final String PROP_CMDLINE_MAIN = "CMD_MAIN";
19     private static final String PROP_CMDLINE_IN = "CMD_IN";
20     private static final String PROP_CMDLINE_OUT = "CMD_OUT";
21     private final File ffmpeg;
22     private final File vhook;
23     private final File optionFile;
24     private final FfmpegOption ffmpegOption;
25
26     public MovieSetting(File ffmpeg, File vhook, File optionFile, FfmpegOption ffmpegOption) {
27         this.ffmpeg = ffmpeg;
28         this.vhook = vhook;
29         this.optionFile = optionFile;
30         this.ffmpegOption = ffmpegOption;
31     }
32
33     public File getFfmpeg() {
34         return ffmpeg;
35     }
36
37     public File getVhook() {
38         return vhook;
39     }
40
41     public File getOptionFile() {
42         return optionFile;
43     }
44
45     public FfmpegOption getFfmpegOption() {
46         return ffmpegOption;
47     }
48
49     public void save(Properties prop) {
50         prop.setProperty(PROP_FFMPEG_PATH, getFfmpeg().getPath());
51         prop.setProperty(PROP_VHOOK_PATH, getVhook().getPath());
52         prop.setProperty(PROP_CMDLINE_EXT, getFfmpegOption().getExtOption());
53         prop.setProperty(PROP_CMDLINE_MAIN, getFfmpegOption().getMainOption());
54         prop.setProperty(PROP_CMDLINE_IN, getFfmpegOption().getInOption());
55         prop.setProperty(PROP_CMDLINE_OUT, getFfmpegOption().getOutOption());
56         if (getOptionFile() != null) {
57             prop.setProperty(PROP_OPTION_FILE, getOptionFile().getPath());
58         } else {
59             prop.remove(PROP_OPTION_FILE);
60         }
61     }
62
63     public static MovieSetting load(Properties prop) {
64         String name = prop.getProperty(PROP_OPTION_FILE);
65         File optionFile = null;
66         if (name != null) {
67             optionFile = new File(name);
68         }
69
70         String ffmpeg = prop.getProperty(PROP_FFMPEG_PATH, ".\\bin\\ffmpeg.exe");
71         String vhook = prop.getProperty(PROP_VHOOK_PATH, ".\\bin\\nicovideo.dll");
72         String ext = prop.getProperty(PROP_CMDLINE_EXT, ".m4v");
73         String main = prop.getProperty(PROP_CMDLINE_MAIN, "");
74         String in = prop.getProperty(PROP_CMDLINE_IN, "");
75         String out = prop.getProperty(PROP_CMDLINE_OUT, "-f ipod");
76         FfmpegOption opt = new FfmpegOption(ext, main, in, out);
77
78         return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
79     }
80 }