OSDN Git Service

通常のメッセージではプログレスバー表示を行わない
[coroid/inqubus.git] / frontend / src / saccubus / worker / impl / convert / Convert.java
index 3f581f3..bcc40f2 100644 (file)
@@ -52,11 +52,13 @@ public class Convert extends Worker<ConvertResult, ConvertProgress> {
      * @param output 変換後出力動画.
      * @throws IOException 変換失敗.
      */
-    public Convert(ConvertProfile profile, File video, File comment, WorkerListener<ConvertResult, ConvertProgress> listener) {
+    public Convert(ConvertProfile profile, File video, File comment,
+            WorkerListener<ConvertResult, ConvertProgress> listener) {
         super(listener);
         this.profile = profile;
         this.videoFile = video;
         this.commentFile = comment;
+        logger.log(Level.INFO, "convert video:{0}, comment:{1}", new Object[]{videoFile, commentFile});
     }
 
     @Override
@@ -84,18 +86,18 @@ public class Convert extends Worker<ConvertResult, ConvertProgress> {
             if (profile.isCommentOverlay()) {
                 transformedComment = File.createTempFile("vhk", ".tmp", profile.getTempDir());
                 final HideCondition hide = profile.getNgSetting();
-                publish(new ConvertProgress(PROCESS, "コメントの中間ファイルへの変換中"));
+                publish(new ConvertProgress(PROCESS, -1.0, "コメントの中間ファイルへの変換中"));
                 ConvertToVideoHook.convert(commentFile, transformedComment, hide.getId(), hide.getWord());
             }
 
             checkStop();
-            publish(new ConvertProgress(PROCESS, "動画の変換を開始"));
+            publish(new ConvertProgress(PROCESS, -1.0, "動画の変換を開始"));
 
             final int code = convert(transformedComment, outputFile);
             if (code != 0) {
                 throw new IOException("ffmpeg実行失敗: " + outputFile.getPath());
             }
-            publish(new ConvertProgress(PROCESS, "変換が正常に終了しました。"));
+            publish(new ConvertProgress(PROCESS, 100.0, "変換が正常に終了しました。"));
             return new ConvertResult(true, outputFile.getName());
         } finally {
             if (transformedComment != null && transformedComment.exists()) {
@@ -191,7 +193,8 @@ public class Convert extends Worker<ConvertResult, ConvertProgress> {
             String msg;
             while ((msg = ebr.readLine()) != null) {
                 if (msg.startsWith("frame=")) {
-                    publish(new ConvertProgress(PROCESS, msg));
+                    // TODO パーセンテージ計算、出力
+                    publish(new ConvertProgress(PROCESS, 0.0, msg));
                 } else if (!msg.endsWith("No accelerated colorspace conversion found")) {
                     logger.log(Level.INFO, msg);
                 }
@@ -236,7 +239,8 @@ public class Convert extends Worker<ConvertResult, ConvertProgress> {
         sb.append(prof.getFontIndex());
         sb.append("|");
         sb.append("--show-user:");
-        sb.append(prof.getMaxNumOfComment());
+        final int dispNum = (prof.getMaxNumOfComment() < 0) ? 30 : prof.getMaxNumOfComment();
+        sb.append(dispNum);
         sb.append("|");
         sb.append("--shadow:");
         sb.append(prof.getShadowIndex());