import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import saccubus.conv.ConvertToVideoHook;
*/
public class Convert extends Worker<ConvertResult, ConvertProgress> {
- private static final Logger logger = Logger.getLogger(Convert.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(Convert.class);
private final ConvertProfile profile;
private final File videoFile;
private final File commentFile;
this.profile = profile;
this.videoFile = video;
this.commentFile = comment;
- logger.log(Level.INFO, "convert video:{0}, comment:{1}", new Object[]{videoFile, commentFile});
+ logger.info("convert video:{}, comment:{}", videoFile, commentFile);
}
@Override
try {
duration = util.getDuration();
} catch (IOException ex) {
- logger.log(Level.FINE, "動画再生時間を取得できませんでした: {0}", target);
+ logger.info("動画再生時間を取得できませんでした: {}", target);
duration = Integer.MAX_VALUE;
}
return executeFfmpeg(arguments, duration);
}
if (!avfilterArgs.isEmpty()) {
cmdList.add("-vfilters");
- final String args = "\"" + join(avfilterArgs, ", ") + "\"";
+ final String args = join(avfilterArgs, ", ");
cmdList.add(args);
}
cmdList.add(output.getPath());
- final StringBuilder argMsg = new StringBuilder();
- argMsg.append("arg:");
- for (String s : cmdList) {
- argMsg.append(" ").append(s);
- }
- logger.log(Level.INFO, argMsg.toString());
+
+ 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;
try {
- logger.log(Level.INFO, "Processing FFmpeg...");
+ logger.info("Processing FFmpeg...");
process = Runtime.getRuntime().exec(cmdList.toArray(new String[0]));
BufferedReader ebr = new BufferedReader(new InputStreamReader(
process.getErrorStream()));
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.log(Level.FINEST, "time:{0}, duration:{1}", new Object[]{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")) {
- logger.log(Level.INFO, msg);
+ logger.warn(msg);
}
checkStop();