OSDN Git Service

新しいバージョンのffmpeg処理時間出力に対応
authoryukihane <yukihane.feather@gmail.com>
Thu, 15 Sep 2011 11:18:19 +0000 (20:18 +0900)
committeryukihane <yukihane.feather@gmail.com>
Thu, 15 Sep 2011 11:18:19 +0000 (20:18 +0900)
frontend/src/saccubus/worker/impl/convert/Convert.java

index 5299af3..0fa9916 100644 (file)
@@ -202,7 +202,7 @@ public class Convert extends Worker<ConvertResult, ConvertProgress> {
         logger.info("arg: {}", cmdList);
         return cmdList;
     }
-    private static final Pattern PATTERN_TIME = Pattern.compile("time=(\\d+)");
+    private static final Pattern PATTERN_TIME = Pattern.compile("time=(\\d+):(\\d+):(\\d+)");
 
     private int executeFfmpeg(final List<String> cmdList, int duration) throws InterruptedException, IOException {
         Process process = null;
@@ -217,10 +217,14 @@ public class Convert extends Worker<ConvertResult, ConvertProgress> {
                     final Matcher m = PATTERN_TIME.matcher(msg);
                     double per = -1.0;
                     if (m.find()) {
-                        final String strTime = m.group(1);
-                        final double time = Double.parseDouble(strTime);
+                        final double hour = Integer.parseInt(m.group(1));
+                        final double min = Integer.parseInt(m.group(2));
+                        final double sec = Integer.parseInt(m.group(3));
+                        final double time = ((hour * 60) + min) * 60 + sec;
                         per = 100.0 * time / duration;
-                        logger.trace("time:{}, duration:{}", time, duration);
+                        if (logger.isTraceEnabled()) {
+                            logger.trace("time:{}, duration:{}", time, duration);
+                        }
                     }
                     publish(new ConvertProgress(PROCESS, per, msg));
                 } else if (!msg.endsWith("No accelerated colorspace conversion found")) {