ソースを参照

MediaProps 添加 formatName 等三个字段

reghao 2 年 前
コミット
bc06adf32c

+ 18 - 0
media/src/main/java/cn/reghao/jutil/media/FFmpegWrapper.java

@@ -9,6 +9,7 @@ import cn.reghao.jutil.media.model.VideoProps;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
+import netscape.javascript.JSObject;
 
 import java.time.LocalDateTime;
 
@@ -97,7 +98,24 @@ public class FFmpegWrapper {
                 }
             }
 
+
             MediaProps mediaProps = new MediaProps(audioProps, videoProps);
+
+            if (format.get("format_name") != null) {
+                String formatName = format.get("format_name").getAsString();
+                mediaProps.setFormatName(formatName);
+            }
+
+            if (format.get("format_long_name") != null) {
+                String formatLongName = format.get("format_long_name").getAsString();
+                mediaProps.setFormatLongName(formatLongName);
+            }
+
+            if (format.get("start_time") != null) {
+                double startTime = format.get("start_time").getAsDouble();
+                mediaProps.setStartTime(startTime);
+            }
+
             // Metadata
             JsonElement tagsElement = format.get("tags");
             if (tagsElement != null) {

+ 27 - 0
media/src/main/java/cn/reghao/jutil/media/model/MediaProps.java

@@ -9,6 +9,9 @@ import java.time.LocalDateTime;
 public class MediaProps {
     private AudioProps audioProps;
     private VideoProps videoProps;
+    private String formatName;
+    private String formatLongName;
+    private Double startTime;
     private LocalDateTime createTime;
 
     public MediaProps(AudioProps audioProps, VideoProps videoProps) {
@@ -24,6 +27,30 @@ public class MediaProps {
         return videoProps;
     }
 
+    public void setFormatName(String formatName) {
+        this.formatName = formatName;
+    }
+
+    public String getFormatName() {
+        return formatName;
+    }
+
+    public void setFormatLongName(String formatLongName) {
+        this.formatLongName = formatLongName;
+    }
+
+    public String getFormatLongName() {
+        return formatLongName;
+    }
+
+    public void setStartTime(Double startTime) {
+        this.startTime = startTime;
+    }
+
+    public Double getStartTime() {
+        return startTime;
+    }
+
     public void setCreateTime(LocalDateTime createTime) {
         this.createTime = createTime;
     }