From 62dc2e5f4b659a838c9d25446420a30adbb5ab97 Mon Sep 17 00:00:00 2001 From: "vasary.daniel" Date: Mon, 11 Apr 2022 19:08:32 +0000 Subject: [PATCH] MediaArea JSON inform git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C33147 --- .../mediacube/executors/tests/SmallTests.java | 13 ++-- .../src/user/commons/mediaarea/MediaArea.java | 60 ++++++++++--------- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/SmallTests.java b/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/SmallTests.java index 62d39221..af726915 100644 --- a/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/SmallTests.java +++ b/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/SmallTests.java @@ -1400,18 +1400,19 @@ public class SmallTests { @Test public void test999995() throws Exception { - // (InformOption_HTML( - long progress[] = { 0, 0 }; - System.setProperty("user.dir", "c:/apps/MediaInfo"); - System.setProperty("jna.library.path", "c:/apps/MediaInfo"); - System.setProperty("java.library.path", "c:/apps/MediaInfo"); +// System.setProperty("user.dir", "c:/apps/MediaInfo"); +// System.setProperty("jna.library.path", "c:/apps/MediaInfo"); +// System.setProperty("java.library.path", "c:/apps/MediaInfo"); MediaArea ma = new MediaArea(Paths.get("d:/output.mov")); - BasicDBObject informJSON = ma.informJSON(); + ma.process(); + BasicDBObject informJSON = ma.getInform(); System.out.println(informJSON.toPrettyString("")); // ma.process(); // System.out.println(ma.getFrameCount()); + +// long progress[] = { 0, 0 }; // // ExternalCommandExecutor executor = new ExternalCommandExecutor(); // executor.execute("profile1", "c:\\_workspace\\data\\video\\1.mxf", "c:\\_video\\test1.mp4", e -> { diff --git a/server/user.jobengine.osgi.commons/src/user/commons/mediaarea/MediaArea.java b/server/user.jobengine.osgi.commons/src/user/commons/mediaarea/MediaArea.java index ee7d6deb..ee6cb3cd 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/mediaarea/MediaArea.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/mediaarea/MediaArea.java @@ -16,6 +16,7 @@ public class MediaArea { private long frameCount; private double frameRate; private String format = ""; + private BasicDBObject inform = null; public MediaArea(Path filePath) { this.filePath = filePath; @@ -53,34 +54,16 @@ public class MediaArea { return format; } - public String inform() { - String result = null; - // auto closable - try (MediaInfo mi = new MediaInfo(filePath.toAbsolutePath().toString())) { - result = mi.inform(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - return result; - } - - public BasicDBObject informJSON() { - BasicDBObject result = null; - // auto closable - try (MediaInfo mi = new MediaInfo(filePath.toAbsolutePath().toString())) { - Map data = InformParser.parse(mi.inform()); - - result = new BasicDBObject(); - for (MediaMetadata md : data.values()) { - result.append(md.getType(), - new BasicDBObject(Collections.unmodifiableMap(md.getMetaData()))); - } - - } catch (Exception ex) { - throw new RuntimeException(ex); - } - return result; - } +// public String inform() { +// String result = null; +// // auto closable +// try (MediaInfo mi = new MediaInfo(filePath.toAbsolutePath().toString())) { +// result = mi.inform(); +// } catch (Exception ex) { +// throw new RuntimeException(ex); +// } +// return result; +// } public void process() throws Exception { // auto closable @@ -92,8 +75,29 @@ public class MediaArea { format = mi.get(StreamKind.Video, 0, "Format").toUpperCase(); frameRate = Double.parseDouble(mi.get(StreamKind.Video, 0, "FrameRate")); frameCount = Integer.parseInt(mi.get(StreamKind.Video, 0, "FrameCount")); + + inform = new BasicDBObject(); + + getInform().put("fileName", filePath.getFileName().toString()); + getInform().put("width", width); + getInform().put("height", height); + getInform().put("displayAspect", displayAspect); + getInform().put("formatProfile", formatProfile); + getInform().put("format", format); + getInform().put("frameRate", frameRate); + getInform().put("frameCount", frameCount); + + Map data = InformParser.parse(mi.inform()); + for (MediaMetadata md : data.values()) { + getInform().append(md.getType(), + new BasicDBObject(Collections.unmodifiableMap(md.getMetaData()))); + } } catch (Exception ex) { throw new Exception(ex); } } + + public BasicDBObject getInform() { + return inform; + } } -- 2.54.0