OSDN Git Service

新しいバージョンのffmpeg処理時間出力に対応
[coroid/inqubus.git] / 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")) {