MediaArea JSON inform
authorvasary.daniel <TFS\vasary.daniel>
Mon, 11 Apr 2022 19:08:32 +0000 (19:08 +0000)
committervasary.daniel <TFS\vasary.daniel>
Mon, 11 Apr 2022 19:08:32 +0000 (19:08 +0000)
git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C33147

server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/SmallTests.java
server/user.jobengine.osgi.commons/src/user/commons/mediaarea/MediaArea.java

index 62d39221813acb457b7ce8cf0f4ab3600c68ce9b..af7269157810d32ca0ddac71078bd36404182201 100644 (file)
@@ -1400,18 +1400,19 @@ public class SmallTests {
 \r
        @Test\r
        public void test999995() throws Exception {\r
-               // (InformOption_HTML(\r
-               long progress[] = { 0, 0 };\r
-               System.setProperty("user.dir", "c:/apps/MediaInfo");\r
-               System.setProperty("jna.library.path", "c:/apps/MediaInfo");\r
-               System.setProperty("java.library.path", "c:/apps/MediaInfo");\r
+//             System.setProperty("user.dir", "c:/apps/MediaInfo");\r
+//             System.setProperty("jna.library.path", "c:/apps/MediaInfo");\r
+//             System.setProperty("java.library.path", "c:/apps/MediaInfo");\r
                MediaArea ma = new MediaArea(Paths.get("d:/output.mov"));\r
-               BasicDBObject informJSON = ma.informJSON();\r
+               ma.process();\r
+               BasicDBObject informJSON = ma.getInform();\r
 \r
                System.out.println(informJSON.toPrettyString(""));\r
 \r
 //             ma.process();\r
 //             System.out.println(ma.getFrameCount());\r
+\r
+//             long progress[] = { 0, 0 };\r
 //\r
 //             ExternalCommandExecutor executor = new ExternalCommandExecutor();\r
 //             executor.execute("profile1", "c:\\_workspace\\data\\video\\1.mxf", "c:\\_video\\test1.mp4", e -> {\r
index ee7d6deb5d24e93dfed9409fcc97039af2a1fb0f..ee6cb3cdd12836e3aef7cab7ffc3f2b81e974d56 100644 (file)
@@ -16,6 +16,7 @@ public class MediaArea {
        private long frameCount;\r
        private double frameRate;\r
        private String format = "";\r
+       private BasicDBObject inform = null;\r
 \r
        public MediaArea(Path filePath) {\r
                this.filePath = filePath;\r
@@ -53,34 +54,16 @@ public class MediaArea {
                return format;\r
        }\r
 \r
-       public String inform() {\r
-               String result = null;\r
-               // auto closable\r
-               try (MediaInfo mi = new MediaInfo(filePath.toAbsolutePath().toString())) {\r
-                       result = mi.inform();\r
-               } catch (Exception ex) {\r
-                       throw new RuntimeException(ex);\r
-               }\r
-               return result;\r
-       }\r
-\r
-       public BasicDBObject informJSON() {\r
-               BasicDBObject result = null;\r
-               // auto closable\r
-               try (MediaInfo mi = new MediaInfo(filePath.toAbsolutePath().toString())) {\r
-                       Map<String, MediaMetadata> data = InformParser.parse(mi.inform());\r
-\r
-                       result = new BasicDBObject();\r
-                       for (MediaMetadata md : data.values()) {\r
-                               result.append(md.getType(),\r
-                                               new BasicDBObject(Collections.<String, Object>unmodifiableMap(md.getMetaData())));\r
-                       }\r
-\r
-               } catch (Exception ex) {\r
-                       throw new RuntimeException(ex);\r
-               }\r
-               return result;\r
-       }\r
+//     public String inform() {\r
+//             String result = null;\r
+//             // auto closable\r
+//             try (MediaInfo mi = new MediaInfo(filePath.toAbsolutePath().toString())) {\r
+//                     result = mi.inform();\r
+//             } catch (Exception ex) {\r
+//                     throw new RuntimeException(ex);\r
+//             }\r
+//             return result;\r
+//     }\r
 \r
        public void process() throws Exception {\r
                // auto closable\r
@@ -92,8 +75,29 @@ public class MediaArea {
                        format = mi.get(StreamKind.Video, 0, "Format").toUpperCase();\r
                        frameRate = Double.parseDouble(mi.get(StreamKind.Video, 0, "FrameRate"));\r
                        frameCount = Integer.parseInt(mi.get(StreamKind.Video, 0, "FrameCount"));\r
+\r
+                       inform = new BasicDBObject();\r
+\r
+                       getInform().put("fileName", filePath.getFileName().toString());\r
+                       getInform().put("width", width);\r
+                       getInform().put("height", height);\r
+                       getInform().put("displayAspect", displayAspect);\r
+                       getInform().put("formatProfile", formatProfile);\r
+                       getInform().put("format", format);\r
+                       getInform().put("frameRate", frameRate);\r
+                       getInform().put("frameCount", frameCount);\r
+\r
+                       Map<String, MediaMetadata> data = InformParser.parse(mi.inform());\r
+                       for (MediaMetadata md : data.values()) {\r
+                               getInform().append(md.getType(),\r
+                                               new BasicDBObject(Collections.<String, Object>unmodifiableMap(md.getMetaData())));\r
+                       }\r
                } catch (Exception ex) {\r
                        throw new Exception(ex);\r
                }\r
        }\r
+\r
+       public BasicDBObject getInform() {\r
+               return inform;\r
+       }\r
 }\r