diff --git a/README.md b/README.md index 0559ece..6df093c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ and bash, you might do something like this: ffmpeg -i /tmp/my/source.mp4 -ss ${i} -t $((i+INCR)) /tmp/my/slice_${i}_$((i+INCR)).mp4 done ``` -With JVCL, you'd write this spec file: +With JVCL, you'd write this spec file and save it to a file (for example `my-spec.jvcl`): ```json { "assets": [ {"name": "src", "path": "/tmp/my/source.mp4"} ], @@ -31,7 +31,7 @@ With JVCL, you'd write this spec file: ``` and then run it like this: ```shell script -jvcl my-spec.json +jvcl my-spec.jvcl ``` Yes, the JVCL is longer, but I think many would agree it is easier to read and maintain. @@ -67,16 +67,40 @@ Unlike most JSON, comments *are* allowed in JVCL spec files: * A line comment starts with `//` and continue to the end of the line * A multi-line block syntax starts with `/*` and ends with `*/` +### Executing a JVCL Spec +To execute a spec stored in the file `my-spec.json`, you would run: +```shell script +jvcl my-spec.jvcl +``` + +#### Scratch Directory +Output assets will be placed in the scratch directory, unless otherwise specified +in the spec file. By default, JVCL will create a new temporary directory to use as the scratch +directory. You can set the scratch directory explicitly using the `-t` or `--temp-dir` option: + +```shell script +jvcl -t /some/tempdir my-spec.json +``` + +#### Command Help +To view a list of all `jvcl` command-line options, run `jvcl -h` or `jvcl --help` + ## Assets -Assets are the inputs: generally image, audio and video files. Assets have a name and a path. +Assets are your media files: generally image, audio and video files. -The path can be a file or a URL. +All assets have a name and a path. Input assets are defined using the `assets` array of a JVCL spec. -Operations produce one or more assets, as specified in the `creates` property of +For input assets, the path can be a file or a URL. URL-based assets will be downloaded +to the scratch directory. This can be overridden using the `dest` property on the asset. + +Operations produce one or more output assets, as specified in the `creates` property of an operation JSON object. +For output assets, the path will be within the scratch directory. +You can override this using the `dest` property on the `creates` object associated with the operation. + ### Asset Properties Assets expose properties that can be referenced in operations. The properties currently exposed are: diff --git a/src/main/java/jvcl/main/JvclOptions.java b/src/main/java/jvcl/main/JvclOptions.java index 2c6a076..5be5512 100644 --- a/src/main/java/jvcl/main/JvclOptions.java +++ b/src/main/java/jvcl/main/JvclOptions.java @@ -5,6 +5,7 @@ import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.cobbzilla.util.main.BaseMainOptions; +import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; import java.io.File; @@ -19,10 +20,8 @@ import static org.cobbzilla.util.json.JsonUtil.json; @Slf4j public class JvclOptions extends BaseMainOptions { - public static final String USAGE_SPEC = "Spec file to run. Default is to read from stdin."; - public static final String OPT_SPEC = "-f"; - public static final String LONGOPT_SPEC = "--file"; - @Option(name=OPT_SPEC, aliases=LONGOPT_SPEC, usage=USAGE_SPEC) + public static final String USAGE_SPEC = "Spec file to run. Set to '-' to read from stdin."; + @Argument(usage=USAGE_SPEC, required=true) @Getter @Setter private File specFile; public JSpec getSpec() { diff --git a/src/test/java/javicle/test/BasicTest.java b/src/test/java/javicle/test/BasicTest.java index e7bd91d..559c29a 100644 --- a/src/test/java/javicle/test/BasicTest.java +++ b/src/test/java/javicle/test/BasicTest.java @@ -6,21 +6,30 @@ import org.junit.Test; import java.io.File; -import static jvcl.main.JvclOptions.LONGOPT_SPEC; +import static org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace; +import static org.cobbzilla.util.daemon.ZillaRuntime.shortError; import static org.cobbzilla.util.io.FileUtil.abs; import static org.cobbzilla.util.io.StreamUtil.loadResourceAsStream; import static org.cobbzilla.util.io.StreamUtil.stream2file; +import static org.junit.Assert.fail; public class BasicTest { - @Test public void testSplit () { runSpec("tests/test_split.json"); } - @Test public void testConcat () { runSpec("tests/test_concat.json"); } - @Test public void testTrim () { runSpec("tests/test_trim.json"); } - @Test public void testOverlay() { runSpec("tests/test_overlay.json"); } + @Test public void testSplitConcatAndTrim () { + runSpec("tests/test_split.jvcl"); + runSpec("tests/test_concat.jvcl"); + runSpec("tests/test_trim.jvcl"); + } + + // @Test public void test4Overlay() { runSpec("tests/test_overlay.jvcl"); } private void runSpec(String specPath) { - @Cleanup("delete") final File specFile = stream2file(loadResourceAsStream(specPath)); - Jvcl.main(new String[]{LONGOPT_SPEC, abs(specFile)}); + try { + @Cleanup("delete") final File specFile = stream2file(loadResourceAsStream(specPath)); + Jvcl.main(new String[]{abs(specFile)}); + } catch (Exception e) { + fail("runSpec("+specPath+") failed: "+shortError(e)+"\n"+getStackTrace(e)); + } } } diff --git a/src/test/resources/tests/test_concat.json b/src/test/resources/tests/test_concat.jvcl similarity index 100% rename from src/test/resources/tests/test_concat.json rename to src/test/resources/tests/test_concat.jvcl diff --git a/src/test/resources/tests/test_overlay.json b/src/test/resources/tests/test_overlay.jvcl similarity index 98% rename from src/test/resources/tests/test_overlay.json rename to src/test/resources/tests/test_overlay.jvcl index 2b7d0d1..adf037f 100644 --- a/src/test/resources/tests/test_overlay.json +++ b/src/test/resources/tests/test_overlay.jvcl @@ -18,7 +18,6 @@ "name": "overlay1", "dest": "src/test/resources/outputs/overlay/" }, - "perform": { "source": "vid1", // main video asset "overlay": "vid2", // overlay this video on the main video diff --git a/src/test/resources/tests/test_split.json b/src/test/resources/tests/test_split.jvcl similarity index 100% rename from src/test/resources/tests/test_split.json rename to src/test/resources/tests/test_split.jvcl diff --git a/src/test/resources/tests/test_trim.json b/src/test/resources/tests/test_trim.jvcl similarity index 100% rename from src/test/resources/tests/test_trim.json rename to src/test/resources/tests/test_trim.jvcl