From b2c830ed4e23001e403105e7a5ebd279c09b1b41 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Tue, 15 Dec 2020 13:08:20 -0500 Subject: [PATCH] all times now in seconds. overlay operation basics are working. --- README.md | 2 +- src/main/java/jvcl/main/Jvcl.java | 2 +- src/main/java/jvcl/main/JvclOptions.java | 4 +++- src/main/java/jvcl/service/Toolbox.java | 6 +++--- src/test/resources/tests/test_overlay.jvcl | 15 ++++++++++++--- src/test/resources/tests/test_split.jvcl | 4 ++-- src/test/resources/tests/test_trim.jvcl | 4 ++-- utils/cobbzilla-utils | 2 +- 8 files changed, 25 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 988dea6..4b8d13a 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ Here is a complex example using multiple assets and operations. "operation": "split", // name of the operation, "creates": "vid1_split_%", // assets it creates, the '%' will be replaced with a counter "split": "vid1", // split this source asset - "interval": "10s" // split every ten seconds + "interval": "10" // split every ten seconds }, { "operation": "concat", // name of the operation, diff --git a/src/main/java/jvcl/main/Jvcl.java b/src/main/java/jvcl/main/Jvcl.java index 5d98fb1..b503ee0 100644 --- a/src/main/java/jvcl/main/Jvcl.java +++ b/src/main/java/jvcl/main/Jvcl.java @@ -31,7 +31,7 @@ public class Jvcl extends BaseMain { final Toolbox toolbox = Toolbox.DEFAULT_TOOLBOX; - final AssetManager assetManager = new AssetManager(toolbox, getOptions().getScratchDir()); + final AssetManager assetManager = new AssetManager(toolbox, getOptions().scratchDir()); Arrays.stream(spec.getAssets()).forEach(assetManager::defineAsset); final OperationEngine opEngine = new OperationEngine(toolbox, assetManager); diff --git a/src/main/java/jvcl/main/JvclOptions.java b/src/main/java/jvcl/main/JvclOptions.java index 5be5512..6ac3b91 100644 --- a/src/main/java/jvcl/main/JvclOptions.java +++ b/src/main/java/jvcl/main/JvclOptions.java @@ -4,6 +4,7 @@ import jvcl.model.JSpec; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; +import org.cobbzilla.util.io.TempDir; import org.cobbzilla.util.main.BaseMainOptions; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; @@ -44,6 +45,7 @@ public class JvclOptions extends BaseMainOptions { public static final String OPT_SCRATCH_DIR = "-t"; public static final String LONGOPT_SCRATCH_DIR = "--temp-dir"; @Option(name=OPT_SCRATCH_DIR, aliases=LONGOPT_SCRATCH_DIR, usage=USAGE_SCRATCH_DIR) - @Getter @Setter private File scratchDir = new File("/tmp"); + @Getter @Setter private File scratchDir = null; + public File scratchDir() { return scratchDir == null ? new TempDir() : scratchDir; } } diff --git a/src/main/java/jvcl/service/Toolbox.java b/src/main/java/jvcl/service/Toolbox.java index 5eaad92..471eb3c 100644 --- a/src/main/java/jvcl/service/Toolbox.java +++ b/src/main/java/jvcl/service/Toolbox.java @@ -18,12 +18,10 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import static java.math.RoundingMode.HALF_EVEN; import static org.cobbzilla.util.daemon.ZillaRuntime.*; import static org.cobbzilla.util.io.FileUtil.*; import static org.cobbzilla.util.json.JsonUtil.*; import static org.cobbzilla.util.system.CommandShell.execScript; -import static org.cobbzilla.util.time.TimeUtil.parseDuration; @Slf4j public class Toolbox { @@ -44,7 +42,9 @@ public class Toolbox { } public static BigDecimal getDuration(String t) { - return big(parseDuration(t)).divide(big(1000), HALF_EVEN); + // we may want to support other time formats. + // for now everything is in seconds + return big(t); } public static Map jsContext(Map ctx) { diff --git a/src/test/resources/tests/test_overlay.jvcl b/src/test/resources/tests/test_overlay.jvcl index 6303338..9f44814 100644 --- a/src/test/resources/tests/test_overlay.jvcl +++ b/src/test/resources/tests/test_overlay.jvcl @@ -12,11 +12,20 @@ } ], "operations": [ + // trim videos so test runs faster { "operation": "trim", "creates": "v1", "trim": "vid1", - "start": "0" + "start": "0", + "end": "60" + }, + { + "operation": "trim", + "creates": "v2", + "trim": "vid2", + "start": "10", + "end": "20" }, { "operation": "overlay", // name of the operation @@ -26,11 +35,11 @@ "height": "1024", // output height in pixes. default is source height "dest": "src/test/resources/outputs/overlay/" }, - "source": "vid1", // main video asset + "source": "v1", // main video asset "start": "30", // when (on the main video timeline) to begin showing the overlay. default is 0 (beginning) "end": "30 + overlay.duration", // when (on the main video timeline) to stop showing the overlay. default is to play the entire overlay "overlay": { - "source": "vid2", // overlay this video on the main video + "source": "v2", // overlay this video on the main video "start": "0", // when (on the overlay video timeline) to begin playback on the overlay. default is 0 (beginning) "end": "overlay.duration", // when (on the overlay video timeline) to end playback on the overlay. default is to play the entire overlay "width": "overlay.width / 2", // how wide the overlay will be, in pixels. default is the full overlay width, or maintain aspect ratio if height was set diff --git a/src/test/resources/tests/test_split.jvcl b/src/test/resources/tests/test_split.jvcl index 1a32fe2..ae81ca4 100644 --- a/src/test/resources/tests/test_split.jvcl +++ b/src/test/resources/tests/test_split.jvcl @@ -20,8 +20,8 @@ }, "split": "vid1", // split this source asset "interval": "10s", // split every ten seconds - "start": "65s", // start one minute and five seconds into the video - "end": "100s" // end 100 seconds into the video + "start": "65", // start one minute and five seconds into the video + "end": "100" // end 100 seconds into the video } ] } diff --git a/src/test/resources/tests/test_trim.jvcl b/src/test/resources/tests/test_trim.jvcl index fc98767..79288ca 100644 --- a/src/test/resources/tests/test_trim.jvcl +++ b/src/test/resources/tests/test_trim.jvcl @@ -10,8 +10,8 @@ "dest": "src/test/resources/outputs/trims/" }, "trim": "vid1_splits", // trim these source assets - "start": "1s", // cropped region starts here, default is zero - "end": "6s" // cropped region ends here, default is end of video + "start": "1", // cropped region starts here, default is zero + "end": "6" // cropped region ends here, default is end of video } ] } diff --git a/utils/cobbzilla-utils b/utils/cobbzilla-utils index 64ef780..a31b368 160000 --- a/utils/cobbzilla-utils +++ b/utils/cobbzilla-utils @@ -1 +1 @@ -Subproject commit 64ef7809a0b7c8a2c34311092d606c75df36a9a7 +Subproject commit a31b3687f1286dac404e99f4a9835323ab6c0329