OSDN Git Service

nicovideo.dll にHD動画かどうかを通知するオプションを追加
authoryukihane <yukihane.feather@gmail.com>
Wed, 3 Aug 2011 15:55:56 +0000 (00:55 +0900)
committeryukihane <yukihane.feather@gmail.com>
Wed, 3 Aug 2011 15:55:56 +0000 (00:55 +0900)
frontend/src/saccubus/converter/FfmpegCommand.java

index 6b47594..64b2eb4 100644 (file)
@@ -135,15 +135,17 @@ public class FfmpegCommand extends AbstractCommand {
             }
         }
 
+        final Info info = MediaInfo.getInfo(new File("bin", "MediaInfo"), videoFile);
+        // 4:3 なら1.33, 16:9 なら1.76
+        boolean isHD = ((double)info.getWidth()/(double)info.getHeight() > 1.5);
         if (ov.isResize()) {
-            final Info info = MediaInfo.getInfo(new File("bin", "MediaInfo"), videoFile);
             final Size scaled = (ov.isAdjustRatio()) ? MediaInfo.adjustSize(info, ov.getResizeWidth(), ov.
                     getResizeHeight()) : new Size(info.getWidth(), info.getHeight());
             cmdList.add("-s");
             cmdList.add(scaled.getWidth() + "x" + scaled.getHeight());
         }
 
-        List<String> avfilterArgs = getAvfilterOptions(ov, addComment, commPath, addTcomment, tcommPath);
+        List<String> avfilterArgs = getAvfilterOptions(ov, addComment, commPath, addTcomment, tcommPath, isHD);
 
         if (!avfilterArgs.isEmpty()) {
             cmdList.add("-vfilters");
@@ -191,14 +193,14 @@ public class FfmpegCommand extends AbstractCommand {
     }
 
     private List<String> getAvfilterOptions(FfmpegOption ov, boolean addComment, String commPath, boolean addTcomment,
-            String tcommPath) throws UnsupportedEncodingException {
+            String tcommPath, boolean isHD) throws UnsupportedEncodingException {
         final List<String> avfilterArgs = new ArrayList<String>();
         final String avfilterOption = ov.getAvfilterOption();
         if (StringUtils.isNotBlank(avfilterOption)) {
             avfilterArgs.add(avfilterOption);
         }
         final String vhookArg = (getFfmpeg().isVhookDisabled())
-                ? null : getVhookArg(addComment, commPath, addTcomment, tcommPath);
+                ? null : getVhookArg(addComment, commPath, addTcomment, tcommPath, isHD);
         if (vhookArg != null) {
             avfilterArgs.add(vhookArg);
         }
@@ -206,7 +208,7 @@ public class FfmpegCommand extends AbstractCommand {
     }
 
     private String getVhookArg(boolean addComment, String commPath, boolean addTcomment,
-            String tcommPath) throws UnsupportedEncodingException {
+            String tcommPath, boolean isHD) throws UnsupportedEncodingException {
         StringBuilder sb = new StringBuilder();
         sb.append("vhext=");
         sb.append(getFfmpeg().getVhook().getPath().replace("\\", "/"));
@@ -244,6 +246,11 @@ public class FfmpegCommand extends AbstractCommand {
         }
         if (getFfmpeg().isCommentOpaque()) {
             sb.append("--enable-opaque-comment");
+            sb.append("|");
+        }
+        if(isHD){
+            sb.append("--aspect-mode:1");
+            sb.append("|");
         }
         return sb.toString();
     }