@@ -174,7 +174,7 @@ Here is a complex example using multiple assets and operations. | |||||
"operation": "split", // name of the operation, | "operation": "split", // name of the operation, | ||||
"creates": "vid1_split_%", // assets it creates, the '%' will be replaced with a counter | "creates": "vid1_split_%", // assets it creates, the '%' will be replaced with a counter | ||||
"split": "vid1", // split this source asset | "split": "vid1", // split this source asset | ||||
"interval": "10s" // split every ten seconds | |||||
"interval": "10" // split every ten seconds | |||||
}, | }, | ||||
{ | { | ||||
"operation": "concat", // name of the operation, | "operation": "concat", // name of the operation, | ||||
@@ -31,7 +31,7 @@ public class Jvcl extends BaseMain<JvclOptions> { | |||||
final Toolbox toolbox = Toolbox.DEFAULT_TOOLBOX; | 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); | Arrays.stream(spec.getAssets()).forEach(assetManager::defineAsset); | ||||
final OperationEngine opEngine = new OperationEngine(toolbox, assetManager); | final OperationEngine opEngine = new OperationEngine(toolbox, assetManager); | ||||
@@ -4,6 +4,7 @@ import jvcl.model.JSpec; | |||||
import lombok.Getter; | import lombok.Getter; | ||||
import lombok.Setter; | import lombok.Setter; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.cobbzilla.util.io.TempDir; | |||||
import org.cobbzilla.util.main.BaseMainOptions; | import org.cobbzilla.util.main.BaseMainOptions; | ||||
import org.kohsuke.args4j.Argument; | import org.kohsuke.args4j.Argument; | ||||
import org.kohsuke.args4j.Option; | 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 OPT_SCRATCH_DIR = "-t"; | ||||
public static final String LONGOPT_SCRATCH_DIR = "--temp-dir"; | public static final String LONGOPT_SCRATCH_DIR = "--temp-dir"; | ||||
@Option(name=OPT_SCRATCH_DIR, aliases=LONGOPT_SCRATCH_DIR, usage=USAGE_SCRATCH_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; } | |||||
} | } |
@@ -18,12 +18,10 @@ import java.util.HashMap; | |||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.concurrent.ConcurrentHashMap; | import java.util.concurrent.ConcurrentHashMap; | ||||
import static java.math.RoundingMode.HALF_EVEN; | |||||
import static org.cobbzilla.util.daemon.ZillaRuntime.*; | import static org.cobbzilla.util.daemon.ZillaRuntime.*; | ||||
import static org.cobbzilla.util.io.FileUtil.*; | import static org.cobbzilla.util.io.FileUtil.*; | ||||
import static org.cobbzilla.util.json.JsonUtil.*; | import static org.cobbzilla.util.json.JsonUtil.*; | ||||
import static org.cobbzilla.util.system.CommandShell.execScript; | import static org.cobbzilla.util.system.CommandShell.execScript; | ||||
import static org.cobbzilla.util.time.TimeUtil.parseDuration; | |||||
@Slf4j | @Slf4j | ||||
public class Toolbox { | public class Toolbox { | ||||
@@ -44,7 +42,9 @@ public class Toolbox { | |||||
} | } | ||||
public static BigDecimal getDuration(String t) { | 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<String, Object> jsContext(Map<String, Object> ctx) { | public static Map<String, Object> jsContext(Map<String, Object> ctx) { | ||||
@@ -12,11 +12,20 @@ | |||||
} | } | ||||
], | ], | ||||
"operations": [ | "operations": [ | ||||
// trim videos so test runs faster | |||||
{ | { | ||||
"operation": "trim", | "operation": "trim", | ||||
"creates": "v1", | "creates": "v1", | ||||
"trim": "vid1", | "trim": "vid1", | ||||
"start": "0" | |||||
"start": "0", | |||||
"end": "60" | |||||
}, | |||||
{ | |||||
"operation": "trim", | |||||
"creates": "v2", | |||||
"trim": "vid2", | |||||
"start": "10", | |||||
"end": "20" | |||||
}, | }, | ||||
{ | { | ||||
"operation": "overlay", // name of the operation | "operation": "overlay", // name of the operation | ||||
@@ -26,11 +35,11 @@ | |||||
"height": "1024", // output height in pixes. default is source height | "height": "1024", // output height in pixes. default is source height | ||||
"dest": "src/test/resources/outputs/overlay/" | "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) | "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 | "end": "30 + overlay.duration", // when (on the main video timeline) to stop showing the overlay. default is to play the entire overlay | ||||
"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) | "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 | "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 | "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 | ||||
@@ -20,8 +20,8 @@ | |||||
}, | }, | ||||
"split": "vid1", // split this source asset | "split": "vid1", // split this source asset | ||||
"interval": "10s", // split every ten seconds | "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 | |||||
} | } | ||||
] | ] | ||||
} | } |
@@ -10,8 +10,8 @@ | |||||
"dest": "src/test/resources/outputs/trims/" | "dest": "src/test/resources/outputs/trims/" | ||||
}, | }, | ||||
"trim": "vid1_splits", // trim these source assets | "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 | |||||
} | } | ||||
] | ] | ||||
} | } |
@@ -1 +1 @@ | |||||
Subproject commit 64ef7809a0b7c8a2c34311092d606c75df36a9a7 | |||||
Subproject commit a31b3687f1286dac404e99f4a9835323ab6c0329 |