OSDN Git Service

MediaInfo設定用のGUI項目と、コンフィグ読み書き処理を実装
authoryukihane <yukihane.feather@gmail.com>
Thu, 15 Sep 2011 15:37:16 +0000 (00:37 +0900)
committeryukihane <yukihane.feather@gmail.com>
Thu, 15 Sep 2011 15:37:16 +0000 (00:37 +0900)
frontend/src/saccubus/worker/impl/convert/Convert.java
frontend/src/saccubus/worker/profile/ConvertProfile.java
frontend/src/yukihane/inqubus/config/Config.java
frontend/src/yukihane/inqubus/config/ConfigConvertProfile.java
frontend/src/yukihane/inqubus/gui/ConfigDialog.java

index 0fa9916..d43d310 100644 (file)
@@ -176,7 +176,7 @@ public class Convert extends Worker<ConvertResult, ConvertProgress> {
                 cmdList.add(opt);
             }
         }
-        final Info info = MediaInfo.getInfo(new File("bin", "MediaInfo"), targetVideoFile);
+        final Info info = MediaInfo.getInfo(profile.getMediaInfo(), targetVideoFile);
         // 4:3 なら1.33, 16:9 なら1.76
         final boolean isHD = ((double) info.getWidth() / (double) info.getHeight() > 1.5);
         if (ffop.isResize()) {
index 6d16e4d..d5a9567 100644 (file)
@@ -45,6 +45,13 @@ public interface ConvertProfile {
      */
     File getVhook();
 
+    /**
+     * @return {@link #isConvert()}がtrueの場合に
+     * 使用するMediaInfo実行ファイル.
+     * それ以外の場合は未定義.
+     */
+    File getMediaInfo();
+
     /** @return 一時作業ディレクトリ. */
     File getTempDir();
 
index 2c18e60..9499567 100644 (file)
@@ -328,6 +328,15 @@ public enum Config {
     public void setFfmpegDllPath(String s) {
         config.setProperty(FFMPEG_DLLPATH, s);
     }
+    private static final String MEDIAINFO_PATH = "ffmpeg.mediainfopath";
+
+    public String getMediaInfoPath() {
+        return config.getString(MEDIAINFO_PATH, "bin/MediaInfo.exe");
+    }
+
+    public void setMediaInfoPath(String s) {
+        config.setProperty(MEDIAINFO_PATH, s);
+    }
     private static final String FFMPEG_PARAM_OPTIONFILE = "ffmpeg.param.optionfile";
 
     public String getFfmpegOptionFile() {
index 45d1c1a..f2b2171 100644 (file)
@@ -21,6 +21,7 @@ public abstract class ConfigConvertProfile implements ConvertProfile {
     private final boolean vhookDisabled;
     private final boolean commentOverlay;
     private final File vhook;
+    private final File mediaInfo;
     private final File tempDir;
     private final File font;
     private final int fontIndex;
@@ -40,6 +41,7 @@ public abstract class ConfigConvertProfile implements ConvertProfile {
         this.vhookDisabled = p.getFfmpegDllDisabled();
         this.commentOverlay = p.getOutputCommentOverlay();
         this.vhook = new File(p.getFfmpegDllPath());
+        this.mediaInfo = new File(p.getMediaInfoPath());
         this.tempDir = new File(p.getSystemTempDir());
         this.font = new File(p.getFontPath());
         this.fontIndex = Integer.parseInt(p.getFontIndex());
@@ -88,6 +90,11 @@ public abstract class ConfigConvertProfile implements ConvertProfile {
     }
 
     @Override
+    public File getMediaInfo() {
+        return mediaInfo;
+    }
+
+    @Override
     public File getTempDir() {
         return tempDir;
     }
index fb734cf..ab1bbf0 100644 (file)
@@ -92,10 +92,9 @@ public class ConfigDialog extends JDialog {
         fldFontIndex = new JTextField();
         final JPanel pnlFfmpeg = new JPanel();
         final JPanel pnlFfmpegBinPath = new JPanel();
-        final JLabel lblFfmpegPath = new JLabel();
-        final JLabel lblFfmpegDllPath = new JLabel();
-        fldFfmpegPath = new JTextField();
-        fldFfmpegDllPath = new JTextField();
+        final JLabel lblFfmpegPath = new JLabel("ffmpeg");
+        final JLabel lblFfmpegDllPath = new JLabel("拡張ライブラリ");
+        final JLabel lblMediaInfoPath = new JLabel("MediaInfo");
         final JPanel pnlNgSetting = new JPanel();
         final JPanel pnlSearch = new JPanel();
 
@@ -478,10 +477,6 @@ public class ConfigDialog extends JDialog {
 
         pnlFfmpegBinPath.setBorder(BorderFactory.createTitledBorder("ファイルパス"));
 
-        lblFfmpegPath.setText("ffmpeg");
-
-        lblFfmpegDllPath.setText("拡張ライブラリ");
-
         final JButton btnFfmpegPath = new JButton("...");
         btnFfmpegPath.addActionListener(
                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldFfmpegPath));
@@ -490,6 +485,10 @@ public class ConfigDialog extends JDialog {
         btnFfmpegDllPath.addActionListener(
                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldFfmpegDllPath));
 
+        final JButton btnMediaInfoPath = new JButton("...");
+        btnMediaInfoPath.addActionListener(
+                new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldMediaInfoPath));
+
         GroupLayout gl_jPanel10 = new GroupLayout(pnlFfmpegBinPath);
         pnlFfmpegBinPath.setLayout(gl_jPanel10);
         gl_jPanel10.setHorizontalGroup(
@@ -497,16 +496,22 @@ public class ConfigDialog extends JDialog {
             .addGroup(gl_jPanel10.createSequentialGroup()
                 .addContainerGap()
                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
+                    .addComponent(lblFfmpegPath)
                     .addComponent(lblFfmpegDllPath)
-                    .addComponent(lblFfmpegPath))
+                    .addComponent(lblMediaInfoPath)
+                )
                 .addPreferredGap(ComponentPlacement.RELATED)
                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
                     .addComponent(fldFfmpegDllPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
-                    .addComponent(fldFfmpegPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
+                    .addComponent(fldFfmpegPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
+                    .addComponent(fldMediaInfoPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
+                )
                 .addPreferredGap(ComponentPlacement.RELATED)
                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
                     .addComponent(btnFfmpegPath, GroupLayout.Alignment.TRAILING)
-                    .addComponent(btnFfmpegDllPath, GroupLayout.Alignment.TRAILING))
+                    .addComponent(btnFfmpegDllPath, GroupLayout.Alignment.TRAILING)
+                    .addComponent(btnMediaInfoPath, GroupLayout.Alignment.TRAILING)
+                )
                 .addContainerGap())
         );
         gl_jPanel10.setVerticalGroup(
@@ -516,12 +521,15 @@ public class ConfigDialog extends JDialog {
                     .addComponent(lblFfmpegPath)
                     .addComponent(fldFfmpegPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                     .addComponent(btnFfmpegPath))
-                .addPreferredGap(ComponentPlacement.RELATED)
                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.BASELINE)
                     .addComponent(lblFfmpegDllPath)
                     .addComponent(fldFfmpegDllPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                     .addComponent(btnFfmpegDllPath))
-                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.BASELINE)
+                    .addComponent(lblMediaInfoPath)
+                    .addComponent(fldMediaInfoPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+                    .addComponent(btnMediaInfoPath))
+            )
         );
 
         pnlFfmpegParam.setBorder(BorderFactory.createTitledBorder("ffmpegパラメータ"));
@@ -788,8 +796,9 @@ public class ConfigDialog extends JDialog {
     private final JCheckBox cbCommentOpaque;
     // ffmpeg
     // ffmpeg - ファイルパス
-    private final JTextField fldFfmpegPath;
-    private final JTextField fldFfmpegDllPath;
+    private final JTextField fldFfmpegPath = new JTextField();
+    private final JTextField fldFfmpegDllPath = new JTextField();
+    private final JTextField fldMediaInfoPath = new JTextField();
     // ffmpeg - ffmpegパラメータ
     private final FfmpegParamPanel pnlFfmpegParam = new FfmpegParamPanel();
     // ffmpeg - その他
@@ -884,6 +893,7 @@ public class ConfigDialog extends JDialog {
          */
         fldFfmpegPath.setText(p.getFfmpegPath());
         fldFfmpegDllPath.setText(p.getFfmpegDllPath());
+        fldMediaInfoPath.setText(p.getMediaInfoPath());
 
         /*
          * ffmpeg - ffmpegパラメータ
@@ -990,6 +1000,7 @@ public class ConfigDialog extends JDialog {
          */
         p.setFfmpegPath(fldFfmpegPath.getText());
         p.setFfmpegDllPath(fldFfmpegDllPath.getText());
+        p.setMediaInfoPath(fldMediaInfoPath.getText());
 
         /*
          * ffmpeg - ffmpegパラメータ